无法在嵌套路由中找到资源(Angular 4)

时间:2018-01-27 16:01:04

标签: angular routes

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { RouterModule} from '@angular/router';
import { HttpModule }    from '@angular/http';
import { FormsModule, ReactiveFormsModule} from '@angular/forms';
import { HttpClientModule } from '@angular/common/http';
import { AppComponent } from './app.component';
import { LoginComponent } from './login/login.component';
import { SidebarNavbarComponent } from './sidebar-navbar/sidebar-navbar.component';
import { APP_BASE_HREF } from '@angular/common';
import { StudentInformationComponent } from './student-information/student-information.component';
import { ClassStatusComponent } from './class-status/class-status.component';
import { AasRegistrationComponent } from './aas-registration/aas-registration.component';
import { AssRegistrationPhase1Component } from './ass-registration-phase1/ass-registration-phase1.component';

@NgModule({
  declarations: [
    AppComponent,
    LoginComponent,
    SidebarNavbarComponent,
    StudentInformationComponent,
    ClassStatusComponent,
    AasRegistrationComponent,
    AssRegistrationPhase1Component
  ],
  imports: [
    BrowserModule,
    RouterModule.forRoot([
      {
        path: 'Login',
        component: LoginComponent
      },
      {
    path: '',
    component: SidebarNavbarComponent,
    children:[
      {
        path: '',
        component: StudentInformationComponent
      },
      {
        path: 'StudentInformation',
        component: StudentInformationComponent
      },
      {
        path: 'ClassStatus',
        component: ClassStatusComponent
      },
      {
        path: 'AASRegistration',
        component: AasRegistrationComponent,
        children:[
          {
            path: 'AASRegistration/selectAASCourse',
            component: AssRegistrationPhase1Component
          }
        ]
      }
    ]
  },
  {
    path: 'test',
    component: AasRegistrationComponent
  }

])
  ],
  providers: [ {provide: APP_BASE_HREF, useValue: '/' }],
  bootstrap: [AppComponent]
})
export class AppModule { }

您可以看到我有组件AssRegistrationPhase1Component,它嵌套在组件AasRegistrationComponent中。 AasRegistrationComponent也嵌套在另一个名为SidebarNavbarComponent的组件中。 当我通过输入地址访问AssRegistrationPhase1Component时:http://localhost:4200/AASRegistration/selectAASRegistration Howerver,我收到错误,因为找不到一些重要的Angular资源:
获取http://localhost:4200/AASRegistration/inline.bundle.js net :: ERR_ABORTED
获取http://localhost:4200/AASRegistration/polyfills.bundle.js net :: ERR_ABORTED
我可以理解,因为这些资源位于http://localhost:4200/inline.bundle.js,而不是http://localhost:4200/AASRegistration/inline.bundle.js。 当我直接访问其母亲也是另一个组件的子组件的子组件时,如何让Angular识别这些资源?

0 个答案:

没有答案