Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
export function preloadUser(userService: UserService) {
return function() {
return userService.getUser().toPromise();
};
}
@NgModule({
...
providers: [
{
provide: APP_INITIALIZER,
multi: true,
useFactory: preloadUser,
deps: [UserService]
}
]
})
export class AppModule {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment