【发布时间】:2016-06-06 16:54:28
【问题描述】:
我开始从现有的 Angular 1 代码库派生一个新项目,目的是使用 ngUpgrade 使用 Angular 2 进行新开发。我已成功将 Angular 2 添加到项目中,但是当我尝试实例化时ngUpgrade 为了引导应用程序的 ng2 端,我收到以下错误:
zone.js:461 Unhandled Promise rejection: Error: [$injector:modulerr] Failed to instantiate module NG2_UPGRADE_0_ due to:
Error: [$injector:unpr] Unknown provider: $$testabilityProvider
http://errors.angularjs.org/1.2.15-build.2399+sha.ca4ddfa/$injector/unpr?p0=%24%24testabilityProvider
at http://localhost:63342/myapp/bower_components/angular/angular.js:78:12
at http://localhost:63342/myapp/bower_components/angular/angular.js:3596:19
at Object.getService [as get] (http://localhost:63342/myapp/bower_components/angular/angular.js:3723:39)
at Object.decorator (http://localhost:63342/myapp/bower_components/angular/angular.js:3652:41)
at eval (http://localhost:63342/myapp/node_modules/@angular/upgrade/src/upgrade_adapter.js:309:25)
at http://localhost:63342/myapp/bower_components/angular/angular.js:3679:37
at Array.forEach (native)
at forEach (http://localhost:63342/myapp/bower_components/angular/angular.js:322:11)
at loadModules (http://localhost:63342/myapp/bower_components/angular/angular.js:3666:5)
at createInjector (http://localhost:63342/myapp/bower_components/angular/angular.js:3606:11)
http://errors.angularjs.org/1.2.15-build.2399+sha.ca4ddfa/$injector/moduler…FSSMS%2FClient%2Fapp%2Fbower_components%2Fangular%2Fangular.js%3A3606%3A11)
at http://localhost:63342/myapp/bower_components/angular/angular.js:78:12
at http://localhost:63342/myapp/bower_components/angular/angular.js:3700:15
at Array.forEach (native)
at forEach (http://localhost:63342/myapp/bower_components/angular/angular.js:322:11)
at loadModules (http://localhost:63342/myapp/bower_components/angular/angular.js:3666:5)
at createInjector (http://localhost:63342/myapp/bower_components/angular/angular.js:3606:11)
at doBootstrap (http://localhost:63342/myapp/bower_components/angular/angular.js:1338:20)
at eval (http://localhost:63342/myapp/node_modules/@angular/upgrade/src/upgrade_adapter.js:348:42)
at ZoneDelegate.invoke (http://localhost:63342/myapp/node_modules/zone.js/dist/zone.js:323:29)
at Object.onInvoke (http://localhost:63342/myapp/node_modules/@angular/core/src/zone/ng_zone_impl.js:45:41)
Error loading http://localhost:63342/myapp/ng2/main.js
我搜索了有关Failed to instantiate module NG2_UPGRADE_0_ 和$$testabilityProvider 的信息,但找不到任何有用的信息。
这是一个相当复杂的项目,因此尝试将其分解为可行的 plunkr 具有挑战性。在我尝试这样做之前,是否有人对此有任何想法?
【问题讨论】:
-
查看调用堆栈,显然调用从 Angular 2 (node_modules/@angular/...) 转到 angularjs (bower_components/angular),因此该过程似乎按预期开始。我对 ngUpgrade 的了解还不够,无法排除我目前所做的问题。
标签: angularjs angular ng-upgrade