如何修复我的 angular 4 路由

how to fix my angular 4 routing

我是 Angular 4 世界的新手,当我想路由到 /moviegroup/:id 时遇到了这个错误。由于某种原因,我无法正常工作

app.routes.ts

import { Routes, RouterModule, PreloadAllModules } from '@angular/router';
import { MovieComponent } from '.é/movie/movie.component';
import { WizardComponent } from './wizard/wizard.component';

const routes: Routes = [
    { path: '', redirectTo: 'home', pathMatch: 'full' },
    { path: 'wizard', component: WizardComponent, pathMatch: 'full' },
    {
        path: 'moviegroup', 
        children: [
            { path: 'moviegroup/:id', component: MovieComponent, pathMatch: 'full' }
        ]
    }
];

export const routing = RouterModule.forRoot(routes, { preloadingStrategy: 
PreloadAllModules });

我可以导航到 http://localhost/wizard, http://localhost/moviegroup but not to http://localhost/moviegroup/ecf84479-c23c-1702-8440-b252591364ec。我收到以下错误:

ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'moviegroup/ecf84479-c23c-1702-8440-b252591364ec'
Error: Cannot match any routes. URL Segment: 'moviegroup/ecf84479-c23c-1702-8440-b252591364ec'

这是我的文件结构:

知道我做错了什么吗?如果需要更多信息,请告诉我!

谢谢,雷吉

从子路径中删除 moviegroup

{
  path: 'moviegroup', 
  children: [
    { path: ':id', component: MovieComponent }
  ]
}

而且除了 redirectTo.

的空路由路径之外,您不需要在任何地方包含 pathMatch: 'full'