Angular Custom Input with Custom Validators -
i have custom input component created. looks this:
const input_value_accessor = { provide: ng_value_accessor, useexisting: forwardref(() => inputcomponent), multi: true }; @component({ selector: 'my-input', providers: [input_value_accessor], template: ` <div> <input #inputmodel="ngmodel" [required]="required" [(ngmodel)]="value" /> </div> ` }) export class mycustominput { @input() required: boolean; }
when use built-in validators required, input marked invalid state, so:
<my-input required="true"> <div> <input required="true" class="ng-invalid" /> </div> </my-input>
problem when have custom validators bind my-input
like:
<my-input checkpassword></my-input>
the parent component gets invalid state like:
<my-input checkpassword class="ng-invalid"> <div> <input /> </div> </my-input>
is there way consolidate state of both input , parent component single validation state can check?
Comments
Post a Comment