Is it It looks like Angular2's FormGroup.patchValue() doesn't push new elements into an array.
For example something like this:
ngOnInit() {
this.form = this.formBuilder.group({
animal: [''],
school: this.formBuilder.group({
name: [''],
}),
students: this.formBuilder.array([this.formBuilder.control('Bob')])
});
setTimeout(() => this.form.patchValue({
animal: 'cat'
school : {name: 'Fraser'},
students: ['Bob gets edited', 'This will not show']
}), 250);
}
Will only update the first element in "students" but it will not insert the second element.
What would I need to do to make it display both elements?
Plunker here.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…