cost 363 ms
如何在 ControlValueAccessor 中啟動變化檢測 (valueChanges)

[英]How to start change detection (valueChanges) inside a ControlValueAccessor

我有一個 formControl,我正在嘗試 setValue 然后觸發更改檢測,以便我的其他組件中的valueChanges會得到我在此處設置的更改 - 但它不起作用。 即使我把 emitEvent: true。 不觸發valueChanges ...

如何使用 ControlValueAccessor 將 Angular 中的自定義輸入標記為已觸摸?

[英]How to mark as touched a custom input in Angular with ControlValueAccessor?

我想要的是如果用戶單擊提交按鈕但沒有填寫所有輸入,我會將所有輸入標記為已觸摸,因為表單上有一個必需的驗證器,空輸入應該有一個紅色邊框。 問題當我將表單的所有輸入標記為已觸摸時,自定義輸入不會更改,也不會添加類: 只有基本輸入有類,這里是 html 的結果,只有基本輸入顯示紅色邊框: 輸入組件i ...

Angular CustomValueAccessor - 輸入值不刷新,當 model 更改值時

[英]Angular CustomValueAccesor - input value is not refreshing, when model make changes to value

問題游樂場: https://stackblitz.com/edit/angular-7nuggp 腳步: 將輸入值設置為-1並模糊 - 觸發handleBlur , Math.abs在值上創建 Math.abs,觸發writeValue並將輸入值設置為1 - 正確再次將輸入值設置為-1並模糊 - ...

實現 ControlValueAccessor 和 Validator 的自定義控件組件與使用 FormGroup 不同步

[英]Custom Control Component Implementing ControlValueAccessor and Validator Not Staying In Sync With Consuming FormGroup

背景: 我有一個自定義的 email 控件組件 ( EmailControlComponent ),它實現了ControlValueAccessor和Validator 。 EmailControlComponent的validate()方法接受單個AbstractControl參數。 根據 An ...

使用 ControlValueAccessor 時如何檢查 formGroup 中的驗證

[英]How can I check the validation in my formGroup when i use ControlValueAccessor

我的app.component中有以下代碼,它是父級 TS html 在我的添加代碼描述組件中,我有另一個組 所以現在當頁面加載時,我有兩個需要的輸入代碼。 當我在輸入字段中鍵入內容並單擊“檢查子表單”時,我可以看到group表單有效,因為兩個輸入都有值。如果我沒有在輸入中輸入任何內容,則grou ...

我看不到 ngModel 的初始值

[英]I can't see initial value to ngModel

我有以下可重用組件code-component HTML 我為此實現了控制值訪問器 TS 所以當我從外面使用這個組件時,我會以這種方式使用它 我的問題是當頁面加載時我沒有得到2 。 當我開始打字時,我得到反映了 database.id 屬性中的 ngModel 更改我的錯誤在哪里? 我怎樣才能從一 ...

Angular ControlValueAccessor如何轉移無效狀態?

[英]Angular ControlValueAccessor how to transfert the invalid status?

我已經使用ControlValueAccessor創建了一個自定義輸入,我可以在 formControl 中使用它並且它工作正常。 現在我想知道表單控件何時被認為無效,無法在我的自定義組件內的輸入上顯示紅色邊框。 這是我的自定義輸入:@Component({ selector: 'app-in ...

Angular | ControlValueAccessor 到非本機輸入

[英]Angular | ControlValueAccessor to non native Input

是否可以在 Angular 中使用ControlValueAccessor制作自定義表單控件,而不是使用 DOM 的本機元素(如輸入、文本區域、單選按鈕),而是使用普通的 div 和 span? 我在谷歌上徘徊尋找這個特定問題的答案,但不幸的是沒有運氣。 ...

你能在控制值訪問器組件中集成錯誤處理嗎

[英]Can you integrate error handling in a control value accessor component

從控制值訪問器的以下設置開始: 表單控件在父組件中定義。 所以我可以將錯誤作為@Input 傳遞給這個'some-datepicker'組件。 但是還有一種方法我不必這樣做,而是將它集成到這個組件本身中? ...

將子 forms 標記為從父表單中全部觸及

[英]Marking child forms as all touched from parent form

我正在使用 angular 中的 ControlValueAccessor 和 Validator 接口處理 angular 中的出生日期組件。 我已經實現了這些接口所需的所有方法@Component({ selector: 'app-birthdate', templateUrl: './ ...

一個自定義 angular 兩態復選框組件問題

[英]A custom angular two-state checkbox component issue

我正在嘗試創建一個自定義復選框組件來替換一個舊的 NG Prime 版本,該版本一直在使用,但希望通過添加一些 aria 點並直接利用更多的復選框屬性使其更精簡/更清潔。 我遇到的問題(我猜)是更新值訪問器/ngmodel,並且可以使用一些關於我顯然缺少的指導...... 我認為我所擁有的已經足夠簡 ...

Angular Reactive Forms vs ngModel,哪個性能更好?

[英]Angular Reactive Forms vs ngModel, which has better performance?

我試圖了解兩者中哪一個具有更好的性能,我猜表單的類型對響應很重要,就我而言,我正在嘗試創建一些 ControlValueAccessor 組件,每個組件都包含一個 mat-autocomplete 字段,目標是使用它在一個更大的響應式表單元素中,我想在 ControlValueAccessor 組 ...

Angular 自定義 FormControl with updateOn blur

[英]Angular custom FormControl with updateOn blur

我有一個反應式表單組,它與 updateOn submit和 updateOn change一起工作得很好。 但是當我切換到 updateOn blur時,在我的自定義表單控件中輸入一個字符后直接觸發所需的錯誤並且永遠不會消失。 此外,當我提交表單時,我的自定義表單控件的所有值都是空的(即使字段已 ...

Angular:自定義表單組件不會對值更改做出反應 - 就像 2 方式數據綁定

[英]Angular: Custom form components do not react to value change - like 2 way data binding

所以我正在創建自己的表單組件,它與本文中的問題類似 https://coryrylan.com/blog/angular-custom-form-controls-with-reactive-forms-and-ngmodel 我在那里分叉代碼來說明這一點...... https://stackbl ...

Angular 反應形式驗證子控件中的所需狀態

[英]Angular reactive form validate required status in child control

我有一個實現ControlValueAccessor和Validator的自定義組件。 該組件在form中使用,當它在 HTML 中創建時,我在自定義控件上設置了formControlName 。 所有這些都很好,但缺少的部分是讓孩子的input控件知道它應該是必需的。 當必需組件中沒有值時,我正在 ...


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