无法读取打字稿中未定义的属性“ push”

时间:2019-11-17 21:27:38

标签: arrays typescript push

我一直试图弄清楚如何将list插入数组并将新数据推入同一数组。

collectionList: [any]; 

//Array defined
  collection: [ 
      {
        Name:any,
        Code:any,
        Location:any,
        Capacity:number,
        Remaining:number

      }
  ]
// Getting data from database in collection array to push inside arrayList
this.collection=[{
      Name:item.Name,
      Code:item.Code,
      Location:item.Location,
      Capacity:item.Capacity,
      Remaining:item.Remaining
    }]

//Then Pushing data to collectionList

if (item.register== true){

      this.collectionList.push(this.collection)

    }

MyOrigional code

0 个答案:

没有答案