2
            import { Injectable, Inject } from '@angular/core';
            import { Subject } from "rxjs/Subject";
            import { CompleterData, CompleterItem } from 'ng2-completer';
            import { ProgramService } from '../program.service';
            import { asEnumerable } from 'linq-es5';
            import { CacheService } from '../../../core/services/cache.service';

            @Injectable()
            export class ProgramIntelligentSearch extends Subject<CompleterItem[]> implements CompleterData {
                constructor(private programService: ProgramService,
                    private cacheService: CacheService,
                    @Inject(Array) private lessonTypes: Array<any>,
                    @Inject(Array) private programTypes: Array<any>,
                    @Inject(Array) private languages: Array<any>
                    ) {
                    super();
                }
      --------------------------------------------------------------------------  
        import { Observable } from "rxjs/Observable";
        import { CompleterItem } from "../components/completer-item";
        export interface CompleterData extends Observable<CompleterItem[]> {
            search(term: string): void;
            cancel(): void;
            convertToItem?(data: any): CompleterItem;
        }
------------------------------------------------------------------
            Use ng build --prod --aot

ERROR in Can't resolve all parameters for ProgramIntelligentSearch in D:/Git/xxxxxxx/Application/Htm l5/src/app/shared/service/search/program-intelligent-search.ts: ([object Object], [object Object], ?, ?, ?)

ERROR in ./src/main.ts Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in 'D:\Git\cosmos-main-html5\App lication\Html5\src' @ ./src/main.ts 4:0-74 @ multi ./src/main.ts

Jason.chen
  • 23
  • 6
  • Hi, there are a lot of reason for this problem. Start by taking a look here https://github.com/angular/angular-cli/issues/4551 and then check your dependencies. – Karbos 538 May 02 '17 at 07:45
  • `@Inject(ProgramService) private programService: ProgramService, @Inject(CacheService) private cacheService: CacheService,` Does this work for you ? – Parth Ghiya May 03 '17 at 08:04

1 Answers1

0

You will have to add @Inject so that its dependency can be resolved.

So for custom services inside your service Inject its dependency with @Inject

In your code replace your custom services with

@Inject(ProgramService) private programService: ProgramService, @Inject(CacheService) private cacheService: CacheService,

You can understand it deeply from this blog. https://blog.thoughtram.io/angular/2015/09/17/resolve-service-dependencies-in-angular-2.html

Parth Ghiya
  • 6,929
  • 2
  • 30
  • 37
  • Thank for your answer. For the ProgramService and CacheService can be resolved. but other array parameter cannot be resovled. – Jason.chen May 04 '17 at 02:34
  • Remove @Inject(Array) for those. – Parth Ghiya May 04 '17 at 02:41
  • @ParhGhiya, Thanks for your support, I have resolved that. Since the generic type parameter is not supported in Angular.Link https://github.com/rangle/angular-2-aot-sandbox#service-with-generic-type-param-top – Jason.chen May 05 '17 at 02:03