1

I'm from PHP backgroun, and started using Angular recently. I'm using Angular 6 and need help on creating multidimensional array. I tried many ways but not working, so please help.

3
  • Hi - Welcome to Stack Overflow. If Milind Singh's reply was helpful, please consider "upvoting" it. Otherwise, please post some of the code you've tried - it would definitely help us better understand how best to help you. Thank you in advance... Commented Dec 11, 2018 at 8:07
  • Using reactive form you can create nested array..Take a look at stackblitz.com/edit/angular-1cgvdf If you click on add company and add project you can see the expected result.. Commented Dec 11, 2018 at 8:07
  • @granny, Reactive form is part of angular..For creating array structure it helps.. first you need to know about differences between the forms at angular.io/guide/forms-overview Commented Dec 11, 2018 at 8:10

1 Answer 1

1

You can use the js Object type for the purpose.

Example:

    let myobj:Object = {
      "employees":[
         {"firstName":"John", "lastName":"Doe"}, 
         {"firstName":"Anna", "lastName":"Smith"},
         {"firstName":"Peter", "lastName":"Jones"}
      ]
   };

https://www.w3schools.com/js/js_json.asp

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

2 Comments

Plz provide a running snippet.
Updated. Just copy and paste in you file.