![](/img/trans.png)
[英]Pushing multiple objects in an array without overwriting other objects in TypeScript & React - Adding to a Favorites list
[英]Adding objects to a list in angular 2 typescript
我在將數據推送到列表中時遇到問題,這是我的代碼。
labelListSelected: Label[];
onChange(object,flag){
if(flag==false){
this.labelListSelected.push(object);
}
console.log(this.labelListSelected);
// console.log(object.Id+" : "+flag);
}
我猜它的空指針,更改為:
labelListSelected:Label [] = [];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.