class AuthService {
isLoggedIn:BehaviorSubject<boolean> = BehaviorSubject<boolean>(false);
checkLogin(http:Http) {
return http.get(...)
.map(result => result.json())
.do(result => this.isLoggedIn.next(result)
}
}
bootstrap(AppComponent, [
HTTP_PROVIDERS,
AuthService,
{ provide: APP_INITIALIZER,
useFactory: (authService:AuthService) => authService.checkLogin(),
deps: [AuthService],
multi: true
}
]);
See also How to pass parameters rendered from backend to angular2 bootstrap method