Here is my setup (super simplified):
template:
<button (click)="doNothing">Show</button>
<h2>{{count}}</h2>
component:
count: number;
constructor(private _dataService: DataService) {
this.init();
}
private init(): void {
this._dataService.getAll().subscribe(res=> { //just a simple http GET here
this.count = res;
console.log(this.count); //logs the correct value, but view not updated
});
}
private doNothing(): void { }
As you may have noticed, I'm using a button that's not doing anything, but unless I click it my view is not updated with the correct value (took me some time to think of this hack). What am I actually doing here and how can I replace it with something not so dumb? All the http samples I found assured me that this should work without any magic, but apparently it doesn't. I'm using beta6
this.init()call from constructor tongOnInit()