检测到Angular 4 Circular依赖性

前端之家收集整理的这篇文章主要介绍了检测到Angular 4 Circular依赖性前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
将Angular Cli升级到1.3.1我现在有一些警告

WARNING in Circular dependency detected:
src\app\work-sessions\work-session-list\work-session-list.routing.ts -> src\app\work-sessions\work-session-list\index.ts -> src\app\work
-sessions\work-session-list\work-session-list.routing.ts

每个类都有这样的结构:

工作会话list.routing.ts

import { Route } from '@angular/router';
import { WorkSessionListComponent } from './index';

export const WorkSessionRoutes: Route[] = [
  {
    path: '',component: WorkSessionListComponent
  },];

Index.ts

export * from './work-session-list.component';
export * from './work-session-list.routing';

工作会议,list.module.ts

import { WorkSessionListComponent } from './work-session-list.component';
import { WorkSessionRoutes } from './work-session-list.routing';
import { DataTableModule } from 'primeng/primeng';
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router';

@NgModule( {
    imports: [RouterModule.forChild( WorkSessionRoutes ),CommonModule,FormsModule],declarations: [WorkSessionListComponent],exports: [WorkSessionListComponent]
} )

export class WorkSessionListModule { }

比在app.routing.ts

export const AppRoutes: Routes = [
      {
        path: 'workSession',loadChildren: './work-sessions/work-session-list/work-session-list.module#WorkSessionListModule'
      }
.
.
.

在app.module中

@NgModule({
imports: [
CommonModule,BrowserAnimationsModule,FormsModule,RouterModule.forRoot(AppRoutes),})
  ],declarations: [
    AppComponent
  ]
  bootstrap: [AppComponent]
})
export class AppModule {}

我怎么解决这个问题?它有效,但我有很多警告

正如警告所说,work-session-list.routing.ts取决于index.ts:
import { WorkSessionListComponent } from './index';

index.ts取决于work-session-list.routing.ts:

export * from './work-session-list.routing';

第一个依赖项不是必需的,因为您可以直接从其源文件导入WorkSessionListComponent:

import { WorkSessionListComponent } from './work-session-list.component';

此更改应解决问题.

原文链接:https://www.f2er.com/angularjs/143817.html

猜你在找的Angularjs相关文章