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

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -