1
我刚刚从angular2的路由器转移到ngrx的路由器。 此外,我正在使用角2 rc4。点击一个链接后,URL更改,但导航不开始
我的路线是这样的:只有
export const: Routes = [
{path: "appRoute1", component: "appComponent1", guards: [HashGuard, hasSelectedGuard]},
{path: "appRoute2", component: "appComponent2", guards: [HashGuard, hasSelectedGuard]},
]
HashGuard有一个函数(构造函数):
protectRoute(candidate : TravesalCandidate){
if (!window.location.hash){
this.router.go(HOME_ADDRESS);
}
return Observable.of(true);
}
同样,HasSelectedGuard只有一个功能:
protectRoute(candidate : TravesalCandidate){
if (!this.currentSelectionService.hasSelectedPerson()){
this.router.go(HOME_ADDRESS);
return Observable.of(false);
}
return Observable.of(true)
}
我正在引导任何需要的,因为我应该有:
bootstrap(AppComponent, [
provideRouter(routes, HashLocationStrategy),
Router,
HashGuard,
CurrentSelectionService
]
我有多个链接sidemenu组件,沿着别人我有appRoute1和appRoute2:
<a [linkTo]="'/appRoute1'"> ... </a>
<a [linkTo]="'/appRoute2'"> ... </a>
当我点击URL变化应该是一个链接,但网页本身并不负载(点击后不发送请求,组件的构造函数不是
帮助很高兴地被赞赏。
对不起,我很困惑,我们正在使用ngrx的路由器。 –
对不起,我检查了'ngrx'标签,但仍然没有看到它:D –
编辑以更好地反映我的设置,谢谢 –