2つの異なるルート設定を、サービス変数値。Angular2:外部値に基づいて特定のルート設定リストの選択性を達成する方法
この節は、外部設定変数の値がtrueの場合、子ルートの1つのリストを使用し、別の場合は2番目のリストを使用します。ルートのパスとレベルは同じです。
例:
親ルート/parent...
(非ターミナルルート)、子ルートの設定if service.value is true
で、それが次のルートの設定、他の
@RouteConfig([
{path: '/', component: ChildComponent, name: 'ChildCmp' },
{path: '/test', component: SecComponent, name: 'SecCmp' },
{path: '/tester', component: OptionalComponent, name: 'ThCmp' }
])
それは以下を使用しますservice.value is false
場合に使用します:
@RouteConfig([
{path: '/', component: ChildComponent, name: 'ChildCmp' },
{path: '/test', component: SecComponent, name: 'SecCmp' }
])
inject
ルート設定リストをリストに追加するか、staテンポはservice.value
に基づいていますか?どのようにこのモジュール性やルート設定の選択可能性を達成するためのアイデアですか?
「角度経路設定を動的/実用的に生成するにはどうすればよいですか」(http://stackoverflow.com/questions/35991639/how-do-i-generate-angular-route-configurations-dynamically-pragmatically) –