Answer the question
In order to leave comments, you need to log in
How to apply formControlName to input?
Good afternoon. I returned here to Angular and remembered that I hadn’t figured out the ControlValueAccessor in any way.
The Custom Component
link generates code like this, where everything is applied directly to the component, not to<ui-input-field>
ng-valid ng-pristin
input
<ui-input-field _ngcontent-c8="" formcontrolname="email" _nghost-c9="" ng-reflect-name="email" class="ng-untouched ng-pristine ng-valid">
<input _ngcontent-c9="">
<span _ngcontent-c9="" class="bar"></span>
<label _ngcontent-c9=""></label>
</ui-input-field>
writeValue(value) {
if (!value || typeof value !== 'string') {
console.log('not value');
return;
}
}
onChange: any = () => {
}
onTouched: any = () => {
}
registerOnChange(fn) {
this.onChange(fn);
}
registerOnTouched(fn) {
this.onTouched(fn);
}
Answer the question
In order to leave comments, you need to log in
Based on your example - link . Example with ControlValueAccessor and added example with FromGroup (file input-control.component.ts )
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question