Cannot read ' push ' of undefined help me please


#1

i want add new item to this array but push cannot work
pages: Array<{title: any, component: any}>;

this.pages.push({title: user , component: “danger” });
error : cannot read ’ push ’ of undefined

please help me to find solution
thank you


#2

You need to initialize your pages array before you use it.


#3

Thank you very much
he is working