我有一个角度4应用程序,我似乎无法构建 - 很多格式。 当我使用
ng build --aot=false
它构建(并运行)很好但是如果我使用
ng build --aot
我收到以下错误:
ERROR in Error: Can't resolve all parameters for DataService in C:/Users/Shane/Documents/Visual Studio 2017/Projects/GG_Website/GG_Website/src/app/shared/services/data.service.ts: (?, [object Object]).
at Error (native)
at syntaxError (C:\Users\Shane\Documents\Visual Studio 2017\Projects\GG_Website\GG_Website\node_modules\@angular\compiler\bundles\compiler.umd.js:1729:34)
at CompileMetadataResolver._getDependenciesMetadata (C:\Users\Shane\Documents\Visual Studio 2017\Projects\GG_Website\GG_Website\node_modules\@angular\compiler\bundles\compiler.umd.js:15816:35)
at CompileMetadataResolver._getTypeMetadata (C:\Users\Shane\Documents\Visual Studio 2017\Projects\GG_Website\GG_Website\node_modules\@angular\compiler\bundles\compiler.umd.js:15684:26)
at CompileMetadataResolver._getInjectableMetadata (C:\Users\Shane\Documents\Visual Studio 2017\Projects\GG_Website\GG_Website\node_modules\@angular\compiler\bundles\compiler.umd.js:15670:21)
at CompileMetadataResolver.getProviderMetadata (C:\Users\Shane\Documents\Visual Studio 2017\Projects\GG_Website\GG_Website\node_modules\@angular\compiler\bundles\compiler.umd.js:15961:40)
at C:\Users\Shane\Documents\Visual Studio 2017\Projects\GG_Website\GG_Website\node_modules\@angular\compiler\bundles\compiler.umd.js:15890:49
at Array.forEach (native)
at CompileMetadataResolver._getProvidersMetadata (C:\Users\Shane\Documents\Visual Studio 2017\Projects\GG_Website\GG_Website\node_modules\@angular\compiler\bundles\compiler.umd.js:15850:19)
at C:\Users\Shane\Documents\Visual Studio 2017\Projects\GG_Website\GG_Website\node_modules\@angular\compiler\bundles\compiler.umd.js:15425:63
at Array.forEach (native)
at CompileMetadataResolver.getNgModuleMetadata (C:\Users\Shane\Documents\Visual Studio 2017\Projects\GG_Website\GG_Website\node_modules\@angular\compiler\bundles\compiler.umd.js:15416:49)
at addNgModule (C:\Users\Shane\Documents\Visual Studio 2017\Projects\GG_Website\GG_Website\node_modules\@angular\compiler\bundles\compiler.umd.js:24268:58)
at C:\Users\Shane\Documents\Visual Studio 2017\Projects\GG_Website\GG_Website\node_modules\@angular\compiler\bundles\compiler.umd.js:24279:14
at Array.forEach (native)
at _createNgModules (C:\Users\Shane\Documents\Visual Studio 2017\Projects\GG_Website\GG_Website\node_modules\@angular\compiler\bundles\compiler.umd.js:24278:26)
at analyzeNgModules (C:\Users\Shane\Documents\Visual Studio 2017\Projects\GG_Website\GG_Website\node_modules\@angular\compiler\bundles\compiler.umd.js:24153:14)
at analyzeAndValidateNgModules (C:\Users\Shane\Documents\Visual Studio 2017\Projects\GG_Website\GG_Website\node_modules\@angular\compiler\bundles\compiler.umd.js:24163:35)
at AotCompiler.analyzeModulesAsync (C:\Users\Shane\Documents\Visual Studio 2017\Projects\GG_Website\GG_Website\node_modules\@angular\compiler\bundles\compiler.umd.js:23797:46)
at CodeGenerator.codegen (C:\Users\Shane\Documents\Visual Studio 2017\Projects\GG_Website\GG_Website\node_modules\@angular\compiler-cli\src\codegen.js:32:14)
at Function.NgTools_InternalApi_NG_2.codeGen (C:\Users\Shane\Documents\Visual Studio 2017\Projects\GG_Website\GG_Website\node_modules\@angular\compiler-cli\src\ngtools_api.js:73:30)
at _donePromise.Promise.resolve.then (C:\Users\Shane\Documents\Visual Studio 2017\Projects\GG_Website\GG_Website\node_modules\@ngtools\webpack\src\plugin.js:391:44)
这是DataService的一部分
import { Injectable } from '@angular/core'
import { Observable } from "rxjs/Observable";
import 'rxjs/add/operator/catch'
import 'rxjs/add/operator/map'
import 'rxjs/add/observable/throw'
import { Http } from '@angular/http';
import { StatusCodes } from './../status-codes';
import { AppError } from "app/common/errors/app-error";
import { NotFoundError } from "app/common/errors/not-found-error";
import { ErrorObservable } from "rxjs/observable/ErrorObservable";
import { BadRequestError } from 'app/common/errors/bad-request-error';
@Injectable()
export class DataService {
constructor(
private _url: string,
private _http: Http) {
}
}
当我不提前使用编译时,这一切都按预期工作。 我错过了什么?
提前编译还有多重要?