我不得不說我剛開始研究Angular2,它看起來很有趣。在同一頁上的兩個Angular2組件
我對這個問題今天偶然在那裏我可以這樣來配置路線:打開
{
path: 'artists',
component: ArtistComponent,
children: [
{ path: ':id', component: ArtistsDetailComponent },
{ path: '', component: ArtistsHomeComponent },
]
},
想法是在左邊顯示藝術家列表(ArtistComponent),並點擊時,會出現此詳細視圖(ArtistsDetailComponent)在右側。
ArtistsComponent模板有它,所以當瀏覽到/ artists /:id我真的看到左側的文章列表和右側的詳細視圖(在這個router-outlet)。
除了我需要讓這兩個組件相互通信,所以當我在詳細視圖中進行更改時,它應該在列表中進行更改。
google搜索的時候,我看到,我應該用變量映射信息一起使用組件選擇:
<artist-detail [artist]="selectedArtist"></artist-detail>
但後來我得到一個錯誤,說我沒有路由器的出口和角度都不知道在哪裏放置ArtistsDetailComponent視圖...
所以專家,請幫助...! :)
請您複製並粘貼確切的錯誤? –
這聽起來像是你可能需要使用[多個銷售點]的時候(https://angular.io/docs/ts/latest/api/router/index/RouterConfig-type-alias.html)不知道這是否你正在尋找什麼,它目前處於一個令人不安的實驗階段,但它可能是值得你花時間來看看 –