2016-10-05 10 views
1

Dartで書かれた複数のネストされたルートをパラメータとして持つAngular 2アプリケーションがあります。2つ以上のルーティングレベルをDartのAngular 2のパラメータでネストする方法

最高レベルのルートは、パラメータ "カテゴリ" を持っているし、完璧に動作します:

@RouteConfig(const [ 
    const Route(path: '/', name: 'Empty', component: Empty, useAsDefault: true), 
    const Route(path: '/categories/:category/...', name: 'Category', component: Category) 
]) 
class AppComponent { /* Content omitted */ } 

HTML:

<a [routerLink]="['Category', {'category': cat['id']}]">{{cat['name']}}</a> 

カテゴリーは、同様に、 "製品" のパラメータを定義するRouteConfigを持っています

@RouteConfig(const [ 
    const Route(path: '/', name: 'Empty', component: Empty, useAsDefault: true), 
    const Route(path: '/products/:product', name: 'Product', component: Product) 
]) 
class Category { /* Content omitted */ } 

このような製品へのリンクを作成しようとすると:

<a [routerLink]="['Category/Product', {'category': id, 'product': product['id']}]">{{product['name']}}</a> 

私は次のエラーを取得する:

Route generator for 'category' was not included in parameters passed. 

私もエラーを以下になったどちらのリンク、中Product./Productを試してみました:

Component "AppComponent" has no route named "Product". 

私は完全なソースをプッシュしていますGithubへ:https://github.com/stijnvanbael/angular2-demo

答えて

1

アリ:

<a [routerLink]="['/Category', {'category': id}, 'Product', {'product': product['id']}]">{{product['name']}}</a> 
+0

ありがとう、それは私にさらに一歩を得た。しかし、 'Category'コンポーネントの出力は、' Category'のルータのアウトレットで再びレンダリングされます。どのように私はそこに 'Product'コンポーネントを取得することができますか? –

+0

申し訳ありませんが、分かりませんか?あなたはルートの最初に '/'を追加しましたか? –

+0

はい、私はしました。しかし、 '/'や '/'を入れても違いはありません。 –

関連する問題