1

Hey need help with reactive forms in Angular 4. I've got the next FormGroup declared:

userForm:FormGroup = new FormGroup ({
    employeenumber: new FormControl(),
    name: new FormControl(),
    lastname: new FormControl(),
    birthdate: new FormControl(),
    phone: new FormControl(),
    email: new FormControl(),
    username: new FormControl(),
    password: new FormControl(),
    blocked: new FormControl(),
    departments: new FormArray([
        new FormControl()
    ])
});

But I want to nest other array inside the departments array. To have something like this:

departments: [
    { department: 'test', roles:['rol1', 'rol2'] }
]

It is possible to nest FormArrays? or what is the best way of doing this.

NTHINGs
  • 123
  • 1
  • 5

1 Answers1

5

I think you are looking for something like this Nested Reactive Forms.

There a Highly Nested one too if you wish .

I couldn't place the whole code here as it is too long and your question wanted to check if it is possible to nest Form Array.Hope this helps

Rahul Singh
  • 19,030
  • 11
  • 64
  • 86