2017-03-02 34 views
1

我試圖使用UpgradeModule來引導我的應用程序,所以我可以使用Angular的anglarJS組件。但我一直在控制檯中發現以下錯誤。請指教。我正在使用angular-cli來打包我的應用程序。我需要在package.json中添加角嗎?因爲即使我做了,我仍然有錯誤。angular-cli上的UpgradeModule錯誤

Unhandled Promise rejection: AngularJS v1.x is not loaded! ; Zone: ; Task: Promise.then ; Value: ZoneAwareError {__zone_symbol__error: Error: AngularJS v1.x is not loaded! at Object.noNg (http://localhost:4200/vendor.bundle.js

回答

2

我今天碰上了同樣的問題,並通過加載AngularJS全局腳本解決。

angular-cli's wiki描述:

You can add Javascript files to the global scope via the apps[0].scripts property in .angular-cli.json . These will be loaded exactly as if you had added them in a tag inside index.html .

This is especially useful for legacy libraries or analytic snippets.

"scripts": [ 
    "global-script.js", 
], 

所以,基本上你只需要在.angular-cli.json文件添加"../node_modules/angular/angular.js"app>scripts

這樣做後,應用程序的構建和工作。一個小警告,但它現在顯示WARNING: Tried to load angular more than once.在控制檯,它可以是multiplepossiblethings,但不是一個錯誤了。

如果/當我找到答案時,我會更新答案。