我不得不说我刚开始研究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)不知道这是否你正在寻找什么,它目前处于一个令人不安的实验阶段,但它可能是值得你花时间来看看 –