如何修复ReferenceError:未在angular2路由中找到或未定义路由器时未定义系统?

时间:2016-09-20 07:31:56

标签: angular router

这是我的路由代码:

const dashboard_routes: Routes = [
{
    path: 'dashboard',
    component: ApplicationComponent,
    children: [
        {
            path: 'product', component: ProductHomeComponent,
            children:[
                {
                    path:'',component: ProductIndex
                },
                {
                    path: 'new', component: NewProductComponent
                },
            ]

        },



        {
            path: '', component: DashboardIndexComponent
        }
    ]

}
]

当我输入" / dashboard / product"或" / dashboard / product / new"在浏览器中 它的工作 但是当我输入" / dashboard / product / xxx"或" / product / *"

之后的任何其他字符 发生问题:  exception image

但如果我输入' / dashboard / *' ,app返回404,其真实;

这是404路线代码:

const dashboardRoutes: Routes = [
    {
        path: 'dashboard',
        loadChildren: 'src/module/dashboard.module#DashboardModule',
    }
];

const appRoutes: Routes = [

    ...dashboardRoutes,

    {
        path: '',
        redirectTo: '/login',
        pathMatch: 'full'
    },

    {path: '**', component: PageNotFoundComponent}

]

export const appRoutingProviders: any[] = [];

export const routing: ModuleWithProviders = RouterModule.forRoot(appRoutes);

如何解决这个问题?

0 个答案:

没有答案