How to use child routes in Angular 2

后端 未结 2 1105
隐瞒了意图╮
隐瞒了意图╮ 2020-12-05 19:47

Angular 2 version: 2.0.0-alpha.44

I\'ve been trying to do routing in Angular 2. Though i was able to do the normal routing done, i am facing some is

2条回答
  •  攒了一身酷
    2020-12-05 20:26

    You just need to import the child component in the routerLink then your code is working fine. For example:

    hello
    

    Here is the working plnkur of your code. Plunker Code

    For more info about this routing see this issue on github here

    Update to Angular 2 beta

    As of Angular 2 beta some changes are here:

    • router-link has been changed to routerLink

    • You can also use useAsDefault : true instead of providing child at the time of routerLink like this -

      {path: '/blabla', components: ABC , name : ABC, useAsDefault: true}

提交回复
热议问题