0

View json image

export class XComponent implements OnInit {
      plans: any;
      totalSubscriber = []
    constructor(activatedRoute: ActivatedRoute) { 
        activatedRoute.data.subscribe((res)=>{
          this.plans = res.plansresolve.data;
        });

All that json data is in plans property. Currently I am hard coding totalSubscriber = [2500,5000, and so on....]

How do I take all the total subscribers from the json data and store it in the array as you see above.

1 Answer 1

1

Use map :

this.totalSubscriber  = this.plans.map((plan) => plan.subscriber_count);
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.