0

I'am new to Angular and TypeScript, i'am trying to implement this one but i couldn't make it possible.

My question is i have an array with multiple nested arrays. every nested array has 'id' value. i need get all the nested array 'id' values and store those values to the new array.

this is what i have right now

[parentArray]
  0: nestedArray
     count: 0
     no: null
     level: null
     id: 1
  1: nestedArray
     count: 0
     no: null
     level: null
     id: 22
  2: nestedArray
     count: 0
     no: null
     level: null
     id: 34

I want an array like this, example - idInformation = [1,22,34].

I tried with filter but it gives all the values, i don't know exactly how to do this in TypeScript. please help me to get this or any help also appreciable.

1 Answer 1

2

It is not about typescript nor about angular, you should get familiar with basic javascript.

And looking at your data sample I suppose you have array of objects, not array of arrays.

const ids = array.map(v => v.id);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.