angular - angular2 and Typescript array - Property 'push' does not exist on type '() => void' -


how init empty array?

test: any[];  //on change want add item array test(){    this.test.push('a'); } 

error ts2339: property 'push' not exist on type '() => void'.

you don't initialize array, test undefined. able use it, initialize way:

test: any[] = []; 

Comments