Angular 角度路由现在可以正常工作了

Angular 角度路由现在可以正常工作了,angular,angular-routing,Angular,Angular Routing,我正在写一个应用程序。在应用程序中有两个文件夹:admin和fron app。 我想要的是,若输入localhost:4200/admin,那个么管理模块将激活,用户应该看到仪表板(localhost:4200/admin/dashboard);如果用户键入localhost:4200/app,则fron-app模块将激活(localhost:4200/app/profile)。 现在,当我输入localhost:4200/app时,就会激活管理模块。怎么了 这是主模块 @NgModule({

我正在写一个应用程序。在应用程序中有两个文件夹:admin和fron app。 我想要的是,若输入localhost:4200/admin,那个么管理模块将激活,用户应该看到仪表板(localhost:4200/admin/dashboard);如果用户键入localhost:4200/app,则fron-app模块将激活(localhost:4200/app/profile)。 现在,当我输入localhost:4200/app时,就会激活管理模块。怎么了

这是主模块

@NgModule({
  declarations: [
    AppComponent,
  ],
  imports: [
    BrowserModule,
    MDBBootstrapModule.forRoot(),
    HttpClientModule,
    ReactiveFormsModule,
    FormsModule,
    MyDateRangePickerModule,
    RouterModule.forRoot(appRoutes, { useHash: true }),
    NgxPermissionsModule.forRoot(),
    AdminModule
  ],
  schemas: [NO_ERRORS_SCHEMA],
  providers: [DashboardService, StatisticService, OfficeService, UserLdapService,
    CommissionService, AuthService, AuthGuard, GoalService, UserService, {
      provide: HTTP_INTERCEPTORS,
      useClass: AuthInterceptor,
      multi: true,
    }],
  bootstrap: [AppComponent]
})
export class AppModule { }
这是主要路线

export const appRoutes: Routes = [

  {
    path: 'admin',
    loadChildren: 'app/admin/admin.module#AdminModule'
  },
  {
    pathMatch:'full',
    path: 'app',
    loadChildren: 'app/front-app/front-app.module#FrontAppModule'
  },
  {
    path: '',
    redirectTo: '',
    pathMatch: 'full'
  }
];
管理模块

@NgModule({
    declarations: [
        AdminComponent,
        DashboardComponent,
    ],
    imports: [
        BrowserModule,
        HttpClientModule,
        RouterModule.forChild(adminRoutes),
        NgxPermissionsModule.forRoot(),
    ],
    exports:[
        RouterModule
    ],
    schemas: [NO_ERRORS_SCHEMA],
    providers: [DashboardService, StatisticService, OfficeService, UserLdapService,
        CommissionService, AuthService, AuthGuard, GoalService, UserService, {
            provide: HTTP_INTERCEPTORS,
            useClass: AuthInterceptor,
            multi: true,
        }],
})
export class AdminModule { }
管理路线

export const adminRoutes: Routes = [
  {
    path: '',
    component: AdminComponent,
    children: [
      {
        pathMatch: 'full',
        path: '',
        redirectTo: 'dashboard',
      },
      {
        path: 'dashboard',
        component: DashboardComponent,
        canActivate: [AuthGuard]
      },
      {
        path: 'login',
        component: LoginComponent
      }
    ]

  },

];
前端应用程序路线

export const frontAppRoutes: Routes = [
  {
    path: '',
    component: FrontAppComponent,
    children: [
      {
        path: 'goals',
        component: GoalsComponent
      },
      {
        path: 'login',
        component: FrontLoginComponent
      },
      {
        path: 'profile',
        component: ProfileComponent
      },
    ]

  },

];

从路径中删除
app
,并添加
重定向到路径

export const appRoutes: Routes = [

  {
    path: 'admin',
    loadChildren: './admin/admin.module#AdminModule'
  },
  {
    pathMatch:'full',
    path: 'app',
    loadChildren: './front-app/front-app.module#FrontAppModule'
  },
  {
    path: '',
    redirectTo: 'app',
    pathMatch: 'full'
  }
]

我更改了如下代码,但应用程序仍然无法运行即使我对管理路由进行注释并转到localhost:4200/app,管理模块的仪表板也会激活(localhost:4200/app#/dashboard)