0
votes

Hi I will be having a 'selectedrow' array list in my ngOninit(). I want to make selection to all row checkboxes which is in 'selectedrow' variable.

https://stackblitz.com/edit/github-4vvqp4-xbrzdy?file=src%2Fapp%2Fapp.component.html

2

2 Answers

0
votes

you want to push some card in to selectedCars.

but selectedCars is not a list, because of that you see ERROR: Cannot read property 'push' of undefined

to fix it just make selectedCars as list (with default value)

selectedCars:any[] = [];
0
votes

You are declaring the selectedCars as type any but you are not assigning it as empty array,so initially the value of selectedCars gets undefined that's why the default selected item is not binding to the table. change the code like this

selectedCars:any[] = [];