[英]How do I make sure a nested form group returns an array of objects in Angular?
我正在 Angular 14 中處理帶有嵌套表單組的表單。 在form.component.ts我有: 請參閱此處的Stackblitz 。 問題我需要residences是一個對象數組。 相反,它本身就是一個 object 。 我該如何解決這個問題? ...
[英]How do I make sure a nested form group returns an array of objects in Angular?
我正在 Angular 14 中處理帶有嵌套表單組的表單。 在form.component.ts我有: 請參閱此處的Stackblitz 。 問題我需要residences是一個對象數組。 相反,它本身就是一個 object 。 我該如何解決這個問題? ...
[英]How can I prefill a form with the user's data in this Angular 14 app?
我正在 Angular 14 中開發一個需要身份驗證/授權的應用程序,這是我使用Keycloak Angular的原因。 我需要用當前登錄用戶的數據預填表格。 為此,我有一項服務: 在組件中,我執行以下步驟: 獲取用戶的email: 然后通過 email 獲取用戶的數據: 嘗試使用用戶數據預填充表 ...
[英]How can I get the user's email from Keycloak in this Angular app?
我正在 Angular 14 中開發一個需要身份驗證/授權的應用程序,這是我使用Keycloak Angular的原因。 我需要從應用程序中獲取當前登錄用戶的數據。 為此,我有一項服務: 我在組件中使用它: 在keycloak.init.ts我有: 問題該服務沒有返回用戶數據,而是拋出500 (I ...
[英]What makes this Angular file uploader fail when browsing for the file?
我正在 Angular 14 開發一個包含表格的應用程序。 表單有一個文件上傳器。 在form.component.ts我有: 在模板中,文件上傳器如下所示: 這里有一個Stackblitz 。 問題盡管文件上傳器在用戶將文件拖到其上時按預期工作,顯示上傳進度,但在瀏覽文件時失敗。 問題我究竟做錯 ...
[英]What makes Keycloak's AuthGuard class throw this error in an Angular 14 app?
我正在 Angular 14 中開發一個需要身份驗證/授權的應用程序,這是我使用Keycloak Angular的原因。 我需要守衛某些路線。 按照說明,我首先安裝了 Keycloak Angular: 在shared/auth-guard.service.ts我有: 我在我的應用程序的路由模塊中 ...
[英]What makes Keycloak Angular throw an error in this Angular 14 app?
我正在 Angular 14 中開發一個需要身份驗證/授權的應用程序,這是我使用Keycloak Angular的原因。 按照說明,我首先安裝了 Keycloak Angular: 然后在fe\src\app\app.module.ts : 我還將silent-check-sso.html添加到s ...
[英]How can I display a reusable errors component in this Angular 14 app?
我正在 Angular 14 開發一個應用程序。 該應用程序旨在在各種組件中包含多個 forms,這就是為什么我認為為錯誤消息創建可重用組件是個好主意。 在form.component.ts我有: 在errors.component.ts我有: 從'@angular/core'導入{組件}; 我調 ...
[英]What causes the failure to validate nested form fields in this Angular 14 app?
我一直在用 Angular 14 和 Angular Material 開發電子商務應用程序。 我在為注冊表的某些字段顯示特定(自定義)驗證消息時遇到了問題。 在表單組件的 Typescript 文件中,我有: 在模板中: 使用此語法也不起作用: 問題雖然我可以為firstName字段(或任何其他 ...
[英]How do I create a model in my Angular shared library?
我正在使用 Angular 14. 我想創建一個項目,我可以在其中容納其他項目使用的通用模型和服務。 我運行這個命令來創建腳手架 這產生了一個目錄結構,其中包括 如何在其中生成 model class? 我試過下面 但我不確定這個錯誤是什么意思,或者我是否以正確的方式生成了 model。 ...
[英]What makes the OrderBy custom pipe fail in in this Angular app?
我一直在用 Angular 14 和 Angular Material 開發電子商務應用程序。 我目前正在處理一個表單,其中包含一個填充了我從restcountries.com獲得的世界所有國家/地區的元素。 在countries.service.ts文件中我有: 我在表單組件中使用服務: 目標我 ...
[英]How can I trigger a function from a modal component that does not include the function in Angular 14?
我一直在用 Angular 14 開發電子商務應用程序。 我目前正在處理一個表格,*只能在接受模式中顯示的“條款和條件”后提交。 FormComponent和ModalComponent是兄弟組件。 在form.component.ts我有: 在表單組件的模板中: 在modal.componen ...
[英]How to wait for bootstrap modal response in angular 13?
我是 angular 的新手,正在嘗試調用引導模式並等待其響應,一切正常,除了它沒有返回任何值: PS:我用的是bootstrap5 CDN版這是我的 bootstrap.component.ts: 我的 bootstrap.component.html: 和我的 parent.componen ...
[英]NG2-Charts - How to change cutout width for doughnut chart
我正在使用 Angular 14、ChartJS (4.1.2) 和 NG2-Charts (4.1.1) 開展公司項目。 我在嘗試更改圓環圖的寬度時遇到了一些麻煩。 我展示了我現在擁有的圖片: 這就是我應該做的: 此時我不需要在圖表里面放文字,我只是想縮小圖表的大小,讓里面的文字很合適。 我已 ...
[英]TypeError: Cannot read properties of undefined (reading 'paramMap')
我正在嘗試為我的 angular 組件編寫單元測試,但我遇到了這個錯誤。 我已經調試了很長時間,但沒有運氣。 感謝任何幫助...我在 spec.ts 中創建了 mockActivatedRoute,但它一直顯示以下錯誤。 為什么paramMap屬性無法讀取? 這是我收到的錯誤消息: 下面是我的代碼 ...
[英]Cdk virtual scroll taking time rendering items after scrolling
我在cdk-virtual-scroll中使用擴展面板。 在擴展面板的 header 中,我必須顯示 4 個值,這導致滾動時渲染項目延遲近一秒。 當我嘗試在擴展面板的 header 中使用單個值時,它工作得非常順利,但是當我顯示 4 個值時,它會減慢滾動時呈現新項目的速度。 ...
[英]Angular 14 does not respect browser compatibility: CSS:inset property used although not supported
我有一個基於 Cordova/Ionic 構建的應用程序,Angular 14。在 Chrome 和 iOS 上一切正常。但是,Android webview 似乎不支持 CSS 的inset -property,這會導致問題,如top: 0; ... top: 0; ... inset: ... ...
[英]Angular compilation error : TS2585 Build:'Promise' only refers to a type, but is being used as a value here. Do you need to change your target library
我正在使用 Visual Studio 2022 處理一個 Angular 項目。當我在項目中包含一個 fileUpload.ts 文件時,它開始在項目中出現編譯錯誤並且它不再起作用。 我需要幫助,該項目不再編譯。 錯誤: Error TS2585 Build:'Promise' 僅引用類型,但在此 ...
[英]Typescript target warnings after Angular 15 update
我將我的 angular 應用程序更新為 Angular 15。它構建正常 - 除非出現如下警告: TypeScript Angular CLI 將編譯器選項“target”和“useDefineForClassFields”分別設置為“ES2022”和“false”。 我的tsconfig.js ...
[英]Angular 14 CLI is not compatible with node version 18.12.1
Angular 15 CLI 與節點版本 18.12.1 兼容。 但在降級到 Angular CLI 14 后,現有節點版本不受支持。 我正在尋找與 Angular 14 CLI 兼容的最大節點版本。 ...
[英]Direct url bar routing works while routerlinks fail - Angular 14
Angular 14 路由器在這里遇到問題。 當我如下建立路線時。 我可以直接點擊 url 加載正確的組件但是如果我使用[routerLink]="['specialUser/']" [routerLink]="['specialUser/coolList']" [routerLink]="[' ...