Angular 2路由3级与空组件

时间:2017-07-17 03:09:44

标签: angular typescript

我在角度2中有问题路由

我需要路由此网址

mydomain/app/page/spk/crtspk

我的文件夹路径

-app
|  --page
|  |--spk
|  |  |--crtspk
|  |  |  |--crtspk.component
|  |  |  |--crtspk.data
|  |  |  |--crtspk.style
|  |  |  |--crtspk.template
|  |  |--spk.module
|  |--page.module
|  --layout
app.component
etc

我想在访问时构建应用

mydomain/app/page = redirect to ->mydomain/app/page/spk/crtspk

和访问时

mydomain/app/page/spk = redirect to ->mydomain/app/page/spk/crtspk

问题是,当我构建时,我收到错误"没有导出的成员' SpkModule'在spk.module上

我已经尝试在page.module

上重定向
export const routes = [
  {path: '', redirectTo: 'crtspk', pathMatch: 'full'},
  {path: 'crtspk', component: CrtSpk}
];

但结果路径是

mydomain/app/page/crtspk

我想要像这样的结果路径

mydomain/app/page/spk/crtspk

我的spk.module路线

import { CrtSpk} from './spk/crtspk/CrtSpk.component';
export const routes = [
  {path: '', redirectTo: 'crtspk', pathMatch: 'full'},
  {path: 'crtspk', component: CrtSpk}
];

@NgModule({
  declarations: [
    CrtSpk,
  ],
  imports: [
    CommonModule,
    FormsModule,
    RouterModule.forChild(routes)
  ],
  schemas:  [ CUSTOM_ELEMENTS_SCHEMA ]
})
export default class SpkModule {
  static routes = routes;
}

这是我的page.module

import { SpkModule} from './spk/spk.module';


export const routes = [
  {path: '', redirectTo: 'spk', pathMatch: 'full'},
  {path: 'spk', component: SpkModule}
];

@NgModule({
  declarations: [
    Autosize,
    OnlyNumber,
    SpkModule
  ],
  imports: [
    CommonModule,
    FormsModule,
    TooltipModule,
    AlertModule,
    DropdownModule,
    WidgetModule,
    NKDatetimeModule,
    Select2Module,
    RouterModule.forChild(routes)
  ]
})
export default class PageModule {
  static routes = routes;
}

希望有人帮我解决问题

0 个答案:

没有答案