Error: Cannot match any routes. URL Segment: - Angular 2

后端 未结 2 1450
粉色の甜心
粉色の甜心 2020-12-29 03:01

I am new to angular2. I am trying to understand how to use multiple in a particular template. I have gone though many QA here but couldn\

2条回答
  •  南笙
    南笙 (楼主)
    2020-12-29 03:03

    Solved myself. Done some small structural changes also. Route from Component1 to Component2 is done by a single . Component2 to Comonent3 and Component4 is done by multiple The resulting contents are :

    Component1.html

    
        
    

    Component2.html

     In Two...Go to 3 ...       
        In Two...Go to 4 ...
    
     
     
    

    The '/two' represents the parent component and ['three']and ['four'] represents the link to the respective children of component2 . Component3.html and Component4.html are the same as in the question.

    router.module.ts

    const routes: Routes = [
    {
        path: '',
        redirectTo: 'one',
        pathMatch: 'full'
    },
    {
        path: 'two',
        component: ClassTwo, children: [
    
            {
                path: 'three',
                component: ClassThree,
                outlet: 'nameThree'
            },
            {
                path: 'four',
                component: ClassFour,
                outlet: 'nameFour'
            }
        ]
    },];
    

提交回复
热议问题