Reputation: 563
I tried to push first object only into array but it's adding all the objects. I have attached the screen shot. I have three fields first is firstname and last name street. I need to show only first object value. but it's showing all the data. How to display first one object, it having multiple objectives also? Below is the CODE URL
https://stackblitz.com/edit/angular-formgroup2-first?file=app%2Fapp.component.ts
Upvotes: 0
Views: 144
Reputation: 5731
Get rid of the mapper, and only push first element
let formArr = <FormArray>this.myForm.controls.users;
formArr.push(fb.group({
firstname: this.users[0].firstname,
lastname: this.users[0].lastname,
street: this.users[0].street
}))
Upvotes: 1