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 –
編輯以更好地反映我的設置,謝謝 –