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无法解析ProgramIntelligentSearch
D:/Git/xxxxxxx/Application/Htm
l5/src/app/shared/service/search/program-intelligent-search.ts: ([object Object], [object Object], ?, ?, ?)
的所有参数
> ./src/main.ts中的错误 找不到模块:错误:无法解析'D:\ Git \ cosmos-main-html5 \ App中的'./$$_gendir/app/app.module.ngfactory' lication \ Html5的\ src”中 @ ./src/main.ts 4:0-74 @ multi ./src/main.ts
答案 0 :(得分:0)
您必须添加@Inject才能解析其依赖关系。
因此,服务中的自定义服务使用@Inject
注入其依赖项在您的代码中用
替换自定义服务@Inject(ProgramService) private programService: ProgramService, @Inject(CacheService) private cacheService: CacheService,
您可以从此博客中深入了解它。 https://blog.thoughtram.io/angular/2015/09/17/resolve-service-dependencies-in-angular-2.html