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.

1
  • yes, its possible, you can see the angular reactive form document Commented Oct 9, 2017 at 17:25

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

2 Comments

Useful links, but lacking examples of nesting components with nested FormArrays.
Ya jack only stand alone stuff

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.