Answer the question
In order to leave comments, you need to log in
How to resolve the state object in a child component?
In general, there is such a state for ui-router'a
export function resolveUser(userService: UserService) {
return userService.get();
}
let homeState = {
parent: 'app',
name: 'home',
url: '/home'
component: HomeComponent,
resolve: [
{ token: 'currentUser', deps: [UserService], resolveFn: resolveUser },
]
};
@Component({
selector: 'app-home',
template: '<app-menu></app-menu>'
})
export class HomeComponent {
@Input('currentUser') user: User; //Здесь все нормально
}
@Component({
selector: 'app-menu',
template: '<div>{{user.name}}</div>'
})
export class MenuComponent {
@Input('currentUser') user: User; //Здесь уже пусто
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question