Here is my code :
@Component({
selector: "foo",
template: `
<span>Init : {{o.init}}</span>
<span>Loaded data : {{o.loadedData}}</span>
`,
providers: [
Services
]
})
export class FooComponent implements OnInit{
constructor (private _services: Services) {}
o: Object
ngOnInit() {
o = {"init": "foo"}
this.services.randomCall()
.subscribe(
res => this.o["loadedData"] = res["loadedData"]
)
}
}
So o.loadedData
doesn't appear everytime due to a race condition between my randomCall()
and the template rendering. What I would like would be to notify angular after having assigned o["loadedData"] = res["loadedData"]
. In angular1, I would have done a call to the scope's digest()
function.
How can I do something similar in angular2 ?
Thanks !
Edit: I added back this, it was a typo.