【发布时间】:2015-09-28 13:11:44
【问题描述】:
我有以下定义的角度应用程序:
var myApp = angular.module('myApp', ['ngRoute','infinite-scroll','geolocation', 'ngAnimate', 'ngTouch','ui.filters', 'AxelSoft','angularLazyImg','wu.masonry','ui.bootstrap','ngSanitize']);
到目前为止,我使用的是 AngularJS 版本 1.2.14。现在我需要使用 AngularJS 表单验证,为了做到这一点,我决定迁移到 Angular 的最新稳定版本 1.4.2。
当我更改了 angular 版本时,事情就坏了,控制台抛出了
未捕获的错误:[$injector:modulerr] 带有以下堆栈跟踪:
错误:$injector:modulerr 模块错误
Failed to instantiate module myApp due to:
TypeError: Cannot read property 'push' of undefined
at http://localhost:8000/static/mobile/js/angularApp/app.js:6:37
at Object.e [as invoke] (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js:39:156)
at d (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js:37:328)
at https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js:37:452
at m (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js:7:322)
at g (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js:37:229)
at https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js:37:398
at m (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js:7:322)
at g (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js:37:229)
at eb (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js:40:503
我已经尝试阅读和理解 angularJS 官方迁移指南,但我无法弄清楚其中的内容,因为我没有在我的代码中使用 $animate(它 $animate 和 $touch 只为另一个注入可以工作的插件,即滑块,而且我也使用过“ngROute 任何地方”)
有没有人知道应该在这里做什么,因为我不知道从哪里开始:)
【问题讨论】:
-
第 6 行有什么?在你的 app.js
-
您的依赖项与您使用的新版本的 Angular 不兼容。转到每个第 3 方站点,然后下载适当的版本以用于 angular 1.4.2 或相应地更改您的凉亭配置。
-
您好 Babajide,这是第 5-6 行的代码,其中我使用 HTTP 拦截器来拦截 HTTP 请求并显示加载器:--------------- -------- myApp.config(function ($httpProvider) { $httpProvider.responseInterceptors.push('myHttpInterceptor');//第6行