Form array validation not working in Angular 2 -
this form object
this.userformgroup = this.fb.group({ name : ["", validators.required], email : "", phone : "" address : this.fb.group({ city : ["", validators.required], state : "" }), hobbies : this.fb.array([ this.fb.group({ name : ["", validators.required] }), ]) })
i have used object in below mentioned html.
<div formarrayname="hobbies"> <div formgroupname="0"> name <input type="text" formcontroln!ame="name"> <br><br> <div *ngif="userformgroup.get('hobbies[0].city').haserror('required')"> city required </div> </div> </div>
other validations working form validations not working.
thanks in advance.
try this
<div *ngif="userformgroup.get('hobbies').controls[i].get('name').errors"> city required </div>
Comments
Post a Comment