路由链接嵌套组件

时间:2017-04-10 11:18:21

标签: angular angular2-routing

我的路由器链接有问题。最初我有这种情况

http://imgur.com/a/Mq1xs

单击组件0的按钮,情况会以这种方式发生变化

http://imgur.com/a/aMLzv

我创建了一个app-routing服务来管理路由

const routes: Routes = [

  { path: '', redirectTo: '/a', pathMatch: 'full'},
  { path: 'a',  component: component 0 },
  { path: 'b', component: component 2 },
  { path: 'c', component: component 3 },
  { path: 'd', component:component 4}
  { path: 'e', component:component 5}


];

我在组件1的模板中添加了<router-outlet></router-outlet>。 这很有效。

现在点击组件3的按钮我就是这种情况

http://imgur.com/a/CcW4i

相反,我有这个

http://imgur.com/a/mubas

我尝试了不同的方法,但没有结果,问题出在哪里?

谢谢

1 个答案:

答案 0 :(得分:0)

我以这种方式解决了

{{1}}

P.S。在这个&#34;版本&#34;我在初始帖子中添加了一些额外的组件。

相关问题