I was wondering how exactly works the onInit, especially when calling some services. Here is my main component :
@Component({
selector: "app",
templateUrl: "app/app.html",
directives: [ROUTER_DIRECTIVES]
})
@RouteConfig(){
...
}
export class AppComponent implements OnInit {
constructor (private _fooManager: FooManager) {}
ngOnInit() {
this._fooManager.fetchAllFoos() // Do a web service call to fetch some data and store them inside the FooManager
}
}
(FooManager
's injection comes from my bootstrap.ts)
then all my other components are using the FooManager's data (especially in their templates). I was wondering if I had to check the status of the call done in the fetchAllFoos
or if the ngOnInit
gives any guarantees that the values are fully loaded ?
If not, I guess one solution would be to give a promise back and then check the promise status.