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

后端 未结 2 1441
粉色の甜心
粉色の甜心 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:12

    please modify your router.module.ts as:

    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'
            },
            {
               path: '',
               redirectTo: 'two',
               pathMatch: 'full'
            }
        ]
    },];
    

    and in your component1.html

    In One

    // Successfully loaded component2.html // Error: Cannot match any routes. URL Segment: 'three' // Error: Cannot match any routes. URL Segment: 'three'

提交回复
热议问题