Angular Material forms validation errors -
i have material form in have input box:
<md-form-field class="input-full-width"> <input mdinput class="form-control emp-info-input" type="text" placeholder="description" formcontrolname="perioddesc"> <md-error *ngif="perioddesc.errors.required">this field required</md-error> </md-form-field>
formbuilder:
this.apprperiod = this.fb.group({ 'perioddesc' : new formcontrol(this.perioddesc, [validators.required,validators.maxlength(50)]) }, {validator: customvalidator.validate});
i following error while loading:
error typeerror: cannot read property 'haserror' of undefined
@ object.testcomponent._co [as updatedirectives] (test.html:33)
@ object.debugupdatedirectives [as updatedirectives] (core.es5.js:13075)
@ checkandupdateview (core.es5.js:12255)
@ callviewaction (core.es5.js:12620)
@ execcomponentviewsaction (core.es5.js:12552)
@ checkandupdateview (core.es5.js:12261)
@ callviewaction (core.es5.js:12620)
@ execembeddedviewsaction (core.es5.js:12578)
@ checkandupdateview (core.es5.js:12256)
@ callviewaction (core.es5.js:12620)
because have control form :
<md-error *ngif="apprperiod.get('perioddesc').errors.required">this field required</md-error>
or
<md-error *ngif="apprperiod.haserror('required', ['perioddesc'])">this field required</md-error>
Comments
Post a Comment