0

I am using push method to create a pre-filled form for editing something in angular but when I use the push method, It pushed the data in 0 index of the parent.

I use this code:

console.log('this is lectures', lectures);

(<FormArray>section.get('lecture')).push(lectures);

console.log('this is lecture of section',section.get('lecture'));

(<FormArray>this.editCourseForm.get('section')).push(section);

and the value of each log is like this:

This is lectures:

value: [lecture1, lecture2] //first output

This is lecture of section:

value: [ [lecture1, lecture2] ] //second output

I expect the first output and I created all my html form based on first output and the result now in my form is the second output, It has destroyed my for loop in html.

This is my whole code (It is not a big code).

UPDATE 1: lectures is an array of objects

georgeawg
  • 48,608
  • 13
  • 72
  • 95
Leo
  • 867
  • 1
  • 15
  • 41

0 Answers0