2016-09-16 93 views
2

我想重定向時刷新page.Before刷新頁面我是默認頁這裏http://localhost/mypage/#/brand,當我刷新頁面 我想重定向http://localhost/mypage/#/homeAngular2重定向到默認頁面

const appRoutes: Routes = [ 
    { path: '', redirectTo: 'home', pathMatch: 'full' }, 
    { path: 'home', component: Home }, 
    { path: 'brand', component: BrandCP }, 
]; 

export const appRoutingProviders: any[] = [] 
export const routing: ModuleWithProviders = RouterModule.forRoot(appRoutes, { useHash: true}); 

回答

0

使用查詢字符串如?redirect=1當你走這brand頁面只是追加值重定向手風琴到您的偏好你想在下一次重新加載然後在品牌的組件只是少於這個重定向查詢參數的價值,如果它是未定義或設置爲零,然後讓他留在頁面上,如果它被設置爲1,則將其重定向到主頁簡單且簡單

相關問題