(Plunker of the problem at hand.)
I'm trying to initialize a number of Angular 2 components programatically from the constructor, like this:
constructor() {
this.cells = [];
for (let i = 0; i < 4; i++)
{
this.cells[i] = new CellComponent();
this.cells[i].setNumber(i+1);
}
console.log(this.cells);
}
However, it seems that even though the console output reads:
I get this as the initial HTML:
What am I missing here? Why aren't the calls to setNumber()
in the constructor reflected in the DOM? Also, why isn't the cellUpdated
event fired when I call setNumber()
?