How can new object push into array ionic new

how can new object push into array ionic 2 new

myArray.push(new MyObject());
1 Like

this myarray=[ ] is where is declared …

i am declraring array in here so this refresh page load

public items:[];

constructor(private navCtrl: NavController) {




This is not a proper declaration, and should be initialized as = [].

In addition to floating in the middle of nowhere and not actually being declared as an object property, this is very poorly named on two fronts: “array” is not a very descriptive name, and this is not an array.

Again we float in the ether, so I have no idea where this is actually being invoked from, but at the time that it is, this.items must actually be an array. See my first comment about initialization.

can you show me 1 simple example


i am just reffer this link but sir its not properly work in ionic 2 …

my page on page enter time all pushing array is cleaned how can i stop him.

i think declaring array problem

What if I am pushing an object into an array of objects?