Angular2 - Error: Can't resolve all parameters for IconService

前端 未结 6 905
南旧
南旧 2021-01-19 00:32

I\'ve been trying to switch my app over to AoT compilation and have been getting this error in the production environment when the app is loading (it works fine locally).

6条回答
  •  伪装坚强ぢ
    2021-01-19 00:57

    I have encountered similar problem. I solved it by changing export order in the barrel.

    Basic service files:

    // dependency.service.ts
    @Injectable()
    export class DependencyService { }
    
    // dependant.service.ts
    import { DependencyService } from '.';
    
    @Injectable()
    export class DependantService {
        constructor(private dependency: DependencyService) { }
    }
    

    Following barrel causes the error:

    // index.ts
    export * from './dependant.service';
    export * from './dependency.service';
    

    While following one works:

    // index.ts
    export * from './dependency.service';
    export * from './dependant.service';
    

提交回复
热议问题