0

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

Spy1984
  • 89
  • 3
  • 12

2 Answers2

0

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[] = [];
miladfm
  • 1,508
  • 12
  • 20
0

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[] = [];
Sivaramakrishnan
  • 689
  • 1
  • 4
  • 11
  • Hi Siva, I have updated that code but still it not highlighting the row or checkbox selection is not coming. https://stackblitz.com/edit/github-4vvqp4-4cggas?file=src/app/app.component.ts – Spy1984 Feb 25 '19 at 06:07