'router-outlet' is not a known element

后端 未结 12 1239
无人及你
无人及你 2021-01-30 19:36

I have a mvc 5 project with a angular frontend . I wanted to add routing as described in this tutorial https://angular.io/guide/router. So in my _Layout.cshtml I ad

12条回答
  •  误落风尘
    2021-01-30 19:48

    Assuming you are using Angular 6 with angular-cli and you have created a separate routing module which is responsible for routing activities - configure your routes in Routes array.Make sure that you are declaring RouterModule in exports array. Code would look like this:

    @NgModule({
          imports: [
          RouterModule,
          RouterModule.forRoot(appRoutes)
         // other imports here
         ],
         exports: [RouterModule]
    })
    export class AppRoutingModule { }
    

提交回复
热议问题