how to push object in array in angular from an api

Solutions on MaxInterview for how to push object in array in angular from an api by the best coders in the world

we are a community of more than 2 million smartest coders
registration for
employee referral programs
are now open
get referred to google, amazon, flipkart and more
register now
  
pinned-register now
showing results for - "how to push object in array in angular from an api"
Yannick
08 Mar 2020
1import { Component } from '@angular/core';
2selector: 'my-app',
3styleUrls: [ './app.component.css' ]
4export class AppComponent {
5name = 'Angular';
6myArray = [1, 2, 3, 4, 5, 6];
7addNew(){
8myArray. push(this. myArray. length + 1);