我需要做一個可選的前綴指示語言。 所以,你可以去如何在角度2中創建可選的根狀態?
random-domain.com/
的默認語言將被選中(EN)
,如果你有選擇的語言
隨機-domain.com/ru
語言將被選中 - 茹
,這應該適用於嵌套路線
random-domain.com/some-rand-entity和random-domain.com/ru/some-蘭德實體
我不工作的解決方案 - 一個例子
const app_common: Routes = [ ...];
export const app_routes: Routes = [
{
path: '',
component: HomeComponent,
resolve: {
settings: SettingsStore
},
pathMatch: 'full'
}
];
export const lang_routes: Routes = [
{
path: ':lang',
component: HomeComponent,
resolve: {
languages: LanguagesStore
},
children: app_common,
pathMatch: 'full'
}
];
export const routes: Routes = [
...app_routes,
...app_common,
...lang_routes,
...checkoutRoutes
];
應該是可選 –
是的,但怎麼樣的孩子? Withot孩子工作,但與 - 沒有 –
我想你需要添加相同的孩子到兩條路線。 –