Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/30.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 4后出错无法使用';在';操作员搜索';供应商';无效_Angular_Angular2 Routing_Angular Cli - Fatal编程技术网

升级到angular 4后出错无法使用';在';操作员搜索';供应商';无效

升级到angular 4后出错无法使用';在';操作员搜索';供应商';无效,angular,angular2-routing,angular-cli,Angular,Angular2 Routing,Angular Cli,更新到angular 4后,在使用angular cli进行构建期间,我始终会遇到相同的错误: ERROR in Cannot use 'in' operator to search for 'providers' in null 这是我的app.modules.ts: const authenticatedRoutes: Route[] = [ { path: 'app', component: TsComponent, chil

更新到angular 4后,在使用angular cli进行构建期间,我始终会遇到相同的错误:

ERROR in Cannot use 'in' operator to search for 'providers' in null 
这是我的app.modules.ts:

const authenticatedRoutes: Route[] = [
      {
        path: 'app',
        component: TsComponent,
        children: routingConfig
      },
      { path: '**', redirectTo: 'app/cockpit', pathMatch: 'full' }
    ];

const routes: Route[] = [
  { path: 'login', component: LoginComponent, canActivate: [StartupActivationGuard] }
];

@NgModule({
  declarations: [
    AppComponent,
    LoginComponent
  ],
  imports: [
    BrowserModule,
    FormsModule,
    GlobalSharedModule.forRoot(),
    TsModule,
    AuthModule.forRoot(),
    StartupModule.forRoot(),
    MaterialModule,
    RouterModule.forRoot(routes)
  ],
  providers: [
    { provide: ErrorHandler , useClass: TimeShepherdExceptionHandler }
  ],
  entryComponents: [AppComponent],
  bootstrap: [AppComponent]
})
export class AppModule {

}


authenticatedRoutes.reduce((routeCollection, route: Route) => {
  route.canActivate = defaultGuards;
  routeCollection.push(route);
  return routeCollection;
}, routes);

const appRouterProviders = RouterModule.forRoot(routes);
下面是我的app.routes.ts:

const defaultGuards: any[] = [
  AuthActivationGuard
];

const authenticatedRoutes: Route[] = [
  { path: '', redirectTo: 'app/cockpit', pathMatch: 'full' },
  {
    path: 'app',
    component: TsComponent,
    children: routingConfig
  },
  { path: '**', redirectTo: 'app/cockpit', pathMatch: 'full' }
];

const routes: Route[] = [
  { path: 'login', component: LoginComponent, canActivate: [StartupActivationGuard] }
];

authenticatedRoutes.reduce((routeCollection, route: Route) => {
  route.canActivate = defaultGuards;
  routeCollection.push(route);
  return routeCollection;
}, routes);

export const appRouterProviders = RouterModule.forRoot(routes);
export const routingConfig = [
  { path: 'start', component: StartComponent },
  { path: 'logbook', component: LogBookComponent },
  { path: 'example', component: ExampleComponent },
  { path: 'dev', component: DevComponent },
  { path: 'journal', component: JournalComponent},
  { path: 'cockpit', component: CockpitComponent},
  { path: 'reports', component: ReportsComponent}
];
export const routing = RouterModule.forChild(routingConfig);
我还使用另一个目录ts/ts.routes.ts中的子路由:

const defaultGuards: any[] = [
  AuthActivationGuard
];

const authenticatedRoutes: Route[] = [
  { path: '', redirectTo: 'app/cockpit', pathMatch: 'full' },
  {
    path: 'app',
    component: TsComponent,
    children: routingConfig
  },
  { path: '**', redirectTo: 'app/cockpit', pathMatch: 'full' }
];

const routes: Route[] = [
  { path: 'login', component: LoginComponent, canActivate: [StartupActivationGuard] }
];

authenticatedRoutes.reduce((routeCollection, route: Route) => {
  route.canActivate = defaultGuards;
  routeCollection.push(route);
  return routeCollection;
}, routes);

export const appRouterProviders = RouterModule.forRoot(routes);
export const routingConfig = [
  { path: 'start', component: StartComponent },
  { path: 'logbook', component: LogBookComponent },
  { path: 'example', component: ExampleComponent },
  { path: 'dev', component: DevComponent },
  { path: 'journal', component: JournalComponent},
  { path: 'cockpit', component: CockpitComponent},
  { path: 'reports', component: ReportsComponent}
];
export const routing = RouterModule.forChild(routingConfig);

知道我为什么会出错吗?

此线程表明可能是在某个地方使用了“default”关键字,也可能是某个地方的导入语句不正确。请阅读此处:已尝试未找到任何内容,禁用“默认”导出没有任何影响…我也面临着这个问题!错误没有提供任何关于文件名或页码的信息。我也有这个问题。奇怪的是,一旦应用程序运行,在路由文件中进行保存将使问题消失。似乎第一个ng构建没有正确构建。然后重新编译以某种方式修复它。我注意到的一点是,bundle和chunk的构建顺序与第一次构建到后续构建的顺序不同。后续版本没有错误,而第一个版本有错误。@HarvP在我的应用程序中相同后续版本成功,没有错误,我可以继续开发。真奇怪。