cost 242 ms
從父組件中的子組件訪問 @ViewChild NgForm 引用

[英]Acces @ViewChild NgForm refence from child components in parent component

我有以下應用程序結構: 我想重置 header 中 forms 的狀態和Parent組件的內容。 我嘗試使用父組件中的@ViewChild/@ViewChildren ,但我不知道如何訪問子表單引用。 到目前為止,我被迫在Parent中獲取Header和Content組件的引用並調用resetFor ...

Viewchild 在 then() 中未定義

[英]Viewchild is undefined inside then()

編輯問題是“異步等待”。 我刪除異步等待並返回 Promise。 由於某種原因,async await 中的 then() 丟失了有關 class 對象的數據。 有什么解釋嗎? 謝謝你們:) 問題我有一個 View 子項,當我嘗試在 then() 中使用它時,它是未定義的代碼 ViewChild ...

訪問動態加載的子組件實例

[英]Access dynamically loaded child component instance

要獲取子組件的實例,我知道可以如上所示使用ViewChild 。 它適用於靜態添加的組件,但如果我在 StackBlitz 此處演示的動態添加的組件上使用它,我會在ngAfterViewInit上得到未定義。 獲取動態加載的子組件實例的正確方法是什么? ...

Angular - 動態添加/刪除單個組件的多個實例而無需刷新頁面來更新視圖

[英]Angular - Dynamically adding / removing multiple instances of a single component without having to refresh the page to update the view

這是我第三次嘗試提出這個問題。 這個問題會很長,因為我看不出有什么辦法可以縮短它。 客觀的我想要做的是有一個簡單的網絡應用程序,它有一個 header(我創建為HeaderComponent )和按鈕,一個頁面(我創建為LiveSummaryComponent )將顯示一個的多個實例將顯示不同數據的 ...

從不同的非相關組件訪問組件 ViewContainerRef createComponent() function 導致錯誤

[英]Acessing Component ViewContainerRef createComponent() function from a different non related component results in error

鏈接到更新的問題。 我之前發布過這個問題。 簡要總結一下; 我正在嘗試調用 function,它使用位於非相關組件中的另一個 function 內部的ComponentFactoryResolver和ViewContainerRef創建組件的實例。 具體可以參考上一個問題。 但是,從那時起,我取得 ...

使用 @viewChild nativeElement.value 和插值將模板元素綁定到帶有 ONPUSH CD 的隱藏輸入的值

[英]Using @viewChild nativeElement.value and interpolated values to bind a template element to the value of a hidden input with ONPUSH CD

下面的組件是一個隱藏的輸入組件,它也有一個可見的 span,其目的是始終顯示隱藏輸入的值。 我正在嘗試將隱藏輸入的當前值(它本身動態綁定到該組件之外的另一個組件)到跨度。 為此,我在我的組件中使用了 @ViewChild('hiddenInput') 引用。 雖然我可以 console.log 在代 ...

Angular中@Output和Viewchild有什么區別

[英]What is the difference between @Output and Viewchild in Angular

我在子組件中有下拉菜單,我想在父組件中使用下拉選擇的值。 我有兩個選擇,第一個是使用@Output,第二個是使用@Viewchild。 我混淆了使用哪一個。 哪個是最好的方法,為什么? ...

Angular @viewChild 元素的 "nativeElement: 和 "value" 未定義

[英]Angular @viewChild element's "nativeElement: and "value" are undefined

我在我的組件中使用 @ViewChild 引用: 我正在嘗試訪問我附加了tableCellWidget viewChild 引用的元素的“值”,以便將尾隨 span 元素的[innerHTML]動態設置為通過<select-widget-widget>加載的表單元素的當前值下面<s ...

Angular ViewChild中的組件選擇器和查詢選擇器有什么區別

[英]What is the difference between component selector and query selector in Angular ViewChild

根據Angular ViewChild Documentation , ViewChild Selector 可以是組件類或查詢字符串。 兩者都可以達到相同的結果。 那么這兩者之間有什么區別,什么時候使用什么以及性能方面哪個更好用呢? 和 ...

通過單擊外部 div angular 以編程方式單擊庫中的按鈕

[英]Click button from library programatically by clicking it's outer div angular

我是 Angular 的新手。 @abacritt/angularx-social-login 中的 Google 按鈕只是一個圖標,我想通過將圖標放在旁邊帶有“使用 Google 登錄”字樣的 div 中來更改其外觀。 我只需單擊該圖標即可通過 Google 進行身份驗證,但我無法理解如何通過單 ...

錯誤類型錯誤:無法讀取未定義的屬性(讀取“nativeElement”):我該如何解決?

[英]ERROR TypeError: Cannot read properties of undefined (reading 'nativeElement'): How do I resolve this?

我當前代碼的狀態是這樣的: 在 .ts 文件中,它是這樣的: 但是,菜單沒有打開,並且特定的控制台錯誤仍然存​​在。 我想知道在這種情況下可能有什么問題? 我在 Angular 和編程方面非常陌生,所以如果你寫下正確的代碼,這對我來說意義重大:) ...

Angular:將 class 添加到 CDK 門戶內的 html 元素

[英]Angular: Add class to html element inside a CDK Portal

我有一個帶有 Angular12 和 Angular Material CDK 的應用程序。 我在 CDK 門戶中添加一個模板,模板是這樣的: 我需要將 class 動態添加到#newFormField項,但不知道如何訪問它。 通常,如果這是一個常規的 ng 模板,例如#addressBlock我可 ...

為什么在運行 Angular 單元測試時會創建兩個模擬子組件實例?

[英]Why are two mock child component instances created while running Angular unit tests?

我的 Angular 13 應用程序具有以下內容: 顯示歡迎消息和父組件的應用程序組件 一個父組件,在一個div內顯示一些文本和一個子組件,並監聽子組件的選擇變化,使用@ViewChild獲取子組件 一個子組件,它顯示一個mat-select並通過一個通過公共Observable輸出公開的 ...

@ViewChild 無法訪問 Angular 中子組件的屬性

[英]@ViewChild can´t access properties of child component in Angular

我有一個孩子和一個父組件。 在孩子中,我定義了一個我不想通過@ViewChild 指令和console.log 訪問的屬性,它的值。 但我總是得到類型未定義錯誤。 我錯過了什么? 我還在 afterViewInit() 中使用了 console.log 來確保孩子被渲染。 這是家長: 這是孩子 ...

ViewChild 元素未按預期工作

[英]ViewChild element not working as expected

所以實際上我想做的很簡單我需要從打字稿文件中的模板中引用一個畫布元素 我使用的代碼是@ViewChild('myCanvas', { static: true }) myCanvas: ElementRef<HTMLCanvasElement>; 但它顯示了一個錯誤,指出該變量沒有初始化 ...


 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM