我有一個小的Angular 2應用程序,它從ASP.net MVC Web API中獲取數據。使用認證。我試圖用提前在角2.時間編譯器,我運行以下命令未處理的承諾拒絕AOT(提前)Angular 2
node_modules \ .bin\ngc -p src
但我得到以下錯誤
(node:13640) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): TypeError: Right-hand side of 'instanceof' is not an object (node:13640) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
可以有一個人告訴我如何解決它
This is my directory structure
我有移動tsconfig.json從根到src文件夾,因爲它是在這個link
執導That's how i am using promise
我已經做服務,從我返回的承諾是這樣的:
public get(servicename: string) {
this.colorlog.log('get ' + servicename + " ",enmMessageType.Info);
return this.http.get(this.ngWEBAPISettings.apiServiceBaseUri + "api/" + servicename + "/", this.ngWEBAPISettings.getConfig()).toPromise();
}
像這樣
get() {
var promise = this.setupServicePromise.get(this.SERVICE_NAME);
promise.then((response: any) => {
this.colorlog.log('in then promise ProductComponent get' + response, enmMessageType.Data);
this.vm.Products = response.json();
}).catch((error: any) => {
this.colorlog.log("Error Occurred in product", enmMessageType.Error);
});
}
消費它的成分,這是我的TS .config文件。
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": ["es2015", "dom"],
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true
}
}
你可以分享你tsconfig文件? –
請檢查問題 – rashfmnb
我有這個問題,我通過更新我的角度來更新我的角度2.4.1,我的意思是角/核心,通用,窗體,編譯器,編譯器CLI。試試這個 –