Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular Can';不要从另一个模块跳转_Angular_Router - Fatal编程技术网

Angular Can';不要从另一个模块跳转

Angular Can';不要从另一个模块跳转,angular,router,Angular,Router,我是新来的。我做了说明中的所有操作,但有点错误:我无法加载外部模块中定义/路由的组件 -此代码非常简单。只有3个链接和几个空组件。(app为了简单起见,组件和模块被合并到一个app.ts中) 请查看产品.module.ts。有一句话: @NgModule({ imports: [ RouterModule.forChild( [ { path: 'products', component: ProductsComponent }, // <--- t

我是新来的。我做了说明中的所有操作,但有点错误:我无法加载外部模块中定义/路由的组件

-此代码非常简单。只有3个链接和几个空组件。(
app
为了简单起见,组件和模块被合并到一个app.ts中)

请查看产品.module.ts。有一句话:

@NgModule({
  imports: 
  [ 
    RouterModule.forChild(
    [
      { path: 'products', component: ProductsComponent }, // <--- this goes to NotFoundComponent :(
    ])
  ],
  declarations: [ ProductsComponent ]
})
@NgModule({
进口:
[ 
RouterModule.forChild(
[

{path:'products',component:ProductsComponent},//在
app.module
中切换路由模块

imports: 
  [ 
    BrowserModule,
  /*  RouterModule.forRoot([
      { path: 'welcome', component: WelcomeComponent },
      { path: 'contact', component: ContactComponent },
      { path: '', component: TestComponent },
      { path: '**', component: NotFoundComponent },
    ]),*/
    ProductsModule, //<-- this needs to be above main routing module
    AppRoutingModule     
  ]
导入:
[ 
浏览器模块,
/*RouterModule.forRoot([
{路径:“欢迎”,组件:WelcomeComponent},
{路径:'contact',组件:ContactComponent},
{路径:'',组件:TestComponent},
{路径:'**',组件:NotFoundComponent},
]),*/

ProductsModule,//@tBlabs很高兴能为您提供帮助:-)