Not allowing me to push object into an array

后端 未结 1 1263
北荒
北荒 2021-01-28 02:31

I\'m working with Angular. I\'m trying to push an object into an array but it giving me errors. It says that TypeError: Cannot read property \'push\' of undefined

1条回答
  •  清酒与你
    2021-01-28 03:00

    So if it worked for you and as I saw at least few similar questions latly. If you have TypeError: Cannot read property 'whatever' of undefined that means you didn't declared some property. This is declaration:

    someProperty: SomeType = []
    

    if you have this its only definition:

    someProperty: SomeType
    

    and trying do any operation on it will result in above error.

    0 讨论(0)
提交回复
热议问题