How to add object to array angular 7
Add items in array angular, how to add item to array in angular 7 Often we want to add object in an array on the programming language for Android, java, c ++ .. then we declare an object and then perform add it in the array, those with language programmable angular then you do the samebut with one difference is that you must declare the array like.
Here is the implementation add object in the array with angular 7.
Step 1. Create class object in angular 7
export class fengxiang{or you can create class below:
constructor(public timestamp:string,public direction: number){
}
}
export class CoDeAndroid{Step 2. Create a array with object CoDeAndroid
title: string;
value: number;
}
arrayCode : CoDeAndroid[] = [];Step 3. insert object in array
let code = new CoDeAndroid();Above is the article below about how to add item in array angular 7 if you feel the article is useful for you, please press like like or share your post.
code.title ="Code Android Example";
code.value = 123466;
this.arrayCode.push(code);
Thank you everyone.
No comments:
Post a Comment