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

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);