AngularJS 版本升级后无法读取 属性 未定义错误的“$$state”
Cannot read property '$$state' of undefined error after AngularJS version upgrade
我一直在使用 AngularJS 将我们项目的版本从 1.2.16 升级到 1.6.4。由于我们使用 bower 作为包管理器,我更新了 bower.json 的必要部分如下:
{
"name": "takademi",
"version": "0.0.0",
"dependencies": {
"angular": "1.6.4",
"json3": "~3.3.1",
"es5-shim": "~3.1.0",
"angular-cookies": "1.6.4",
"angular-sanitize": "1.6.4",
"angular-animate": "1.6.4",
"angular-route": "1.6.4",
"angular-bindonce": "~0.3.1",
"restangular": "~1.4.0",
"angular-base64": "~2.0.2",
"lodash": "~2.4.1"
},
"devDependencies": {
"angular-mocks": "1.2.16",
"angular-scenario": "1.2.16"
},
"appPath": "app"
}
这次更新后,我运行 项目。现在我可以看到 angular 的版本为 1.6.4,但出现以下错误:
*** process.env.ENV is not defined, assuming 'prod' env
t @ bundle.js:4776
angular.js:14525 TypeError: Cannot read property '$$state' of undefined
at then (angular.js:16799)
at addPromiseLikeThing (angular-busy.js:67)
at angular-busy.js:22
at Object.forEach (angular.js:403)
at Object.tracker.reset (angular-busy.js:18)
at angular-busy.js:175
at $watchCollectionAction (angular.js:17859)
at Scope.$digest (angular.js:17999)
at Scope.$apply (angular.js:18269)
at done (angular.js:12387)
(anonymous) @ angular.js:14525
getMarketPlace Failed to load resource: the server responded with a status of 401 (Unauthorized)
angular.js:14525 Possibly unhandled rejection: {"data":{"status":401,"module":0,"code":1000,"message":"AUTHENTICATION_REQUIRED","develo perMessage":null,"moreInfo":null},"status":401,"config": {"method":"GET","transformRequest":[null],"transformResponse":[null],"jsonpCallbackParam":"callback","params":{"v":967},"headers":{"Accept":"application/json, text/plain, */*"},"url":"/portal/rest/market-place/getMarketPlace"},"statusText":"Unauthorized"}
(anonymous) @ angular.js:14525
(anonymous) @ angular.js:11008
processChecks @ angular.js:16860
$digest @ angular.js:17971
$apply @ angular.js:18269
done @ angular.js:12387
completeRequest @ angular.js:12613
requestLoaded @ angular.js:12541
据我了解,它只是说明我新升级的 AngularJS 1.6.4 文件不支持其中的 $$state
关键字用法。错误不是来自我们开发的文件,而是来自 Angular 自己的文件。
这是 chrome 浏览器导航我显示错误的功能 - angular.js 的第 16799 行:
function Promise() {
this.$$state = { status: 0 };
}
extend(Promise.prototype, {
then: function(onFulfilled, onRejected, progressBack) {
if (isUndefined(onFulfilled) && isUndefined(onRejected) && isUndefined(progressBack)) {
return this;
}
var result = new Promise();
this.$$state.pending = this.$$state.pending || [];
this.$$state.pending.push([result, onFulfilled, onRejected, progressBack]);
if (this.$$state.status > 0) scheduleProcessQueue(this.$$state);
return result;
},
'catch': function(callback) {
return this.then(null, callback);
},
'finally': function(callback, progressBack) {
return this.then(function(value) {
return handleCallback(value, resolve, callback);
}, function(error) {
return handleCallback(error, reject, callback);
}, progressBack);
}
});
我在 SO 中进行了搜索,Google 搜索了一下,但我找不到任何相关的帖子或对我的问题的解释。大多数答案都与Ruby有关,或者反应:
Uncaught TypeError: Cannot read property 'state' of undefined
由于我不了解 AngularJS 和 bower 的全部功能,因此我不清楚这些答案。
你们能帮帮我吗?
提前致谢!
angular-busy
module 不是由 AngularJS 团队创建的。函数 addPromiseLikeThing
看起来很可疑,它是在进入 $q 库之前执行的最后一件事,它在那里爆炸了。使用 'promiseLike' 对象伪造 $q 库可能是错误的原因。
此外 AngularJS V1.6 更改了处理拒绝的方式。错误信息:
angular.js:14525 Possibly unhandled rejection: {"data":{"status":401,
是这些变化的结果。
有关详细信息,请参阅 AngularJS Developer Guide - Migrating to V1.6 ($q)
我一直在使用 AngularJS 将我们项目的版本从 1.2.16 升级到 1.6.4。由于我们使用 bower 作为包管理器,我更新了 bower.json 的必要部分如下:
{
"name": "takademi",
"version": "0.0.0",
"dependencies": {
"angular": "1.6.4",
"json3": "~3.3.1",
"es5-shim": "~3.1.0",
"angular-cookies": "1.6.4",
"angular-sanitize": "1.6.4",
"angular-animate": "1.6.4",
"angular-route": "1.6.4",
"angular-bindonce": "~0.3.1",
"restangular": "~1.4.0",
"angular-base64": "~2.0.2",
"lodash": "~2.4.1"
},
"devDependencies": {
"angular-mocks": "1.2.16",
"angular-scenario": "1.2.16"
},
"appPath": "app"
}
这次更新后,我运行 项目。现在我可以看到 angular 的版本为 1.6.4,但出现以下错误:
*** process.env.ENV is not defined, assuming 'prod' env
t @ bundle.js:4776
angular.js:14525 TypeError: Cannot read property '$$state' of undefined
at then (angular.js:16799)
at addPromiseLikeThing (angular-busy.js:67)
at angular-busy.js:22
at Object.forEach (angular.js:403)
at Object.tracker.reset (angular-busy.js:18)
at angular-busy.js:175
at $watchCollectionAction (angular.js:17859)
at Scope.$digest (angular.js:17999)
at Scope.$apply (angular.js:18269)
at done (angular.js:12387)
(anonymous) @ angular.js:14525
getMarketPlace Failed to load resource: the server responded with a status of 401 (Unauthorized)
angular.js:14525 Possibly unhandled rejection: {"data":{"status":401,"module":0,"code":1000,"message":"AUTHENTICATION_REQUIRED","develo perMessage":null,"moreInfo":null},"status":401,"config": {"method":"GET","transformRequest":[null],"transformResponse":[null],"jsonpCallbackParam":"callback","params":{"v":967},"headers":{"Accept":"application/json, text/plain, */*"},"url":"/portal/rest/market-place/getMarketPlace"},"statusText":"Unauthorized"}
(anonymous) @ angular.js:14525
(anonymous) @ angular.js:11008
processChecks @ angular.js:16860
$digest @ angular.js:17971
$apply @ angular.js:18269
done @ angular.js:12387
completeRequest @ angular.js:12613
requestLoaded @ angular.js:12541
据我了解,它只是说明我新升级的 AngularJS 1.6.4 文件不支持其中的 $$state
关键字用法。错误不是来自我们开发的文件,而是来自 Angular 自己的文件。
这是 chrome 浏览器导航我显示错误的功能 - angular.js 的第 16799 行:
function Promise() {
this.$$state = { status: 0 };
}
extend(Promise.prototype, {
then: function(onFulfilled, onRejected, progressBack) {
if (isUndefined(onFulfilled) && isUndefined(onRejected) && isUndefined(progressBack)) {
return this;
}
var result = new Promise();
this.$$state.pending = this.$$state.pending || [];
this.$$state.pending.push([result, onFulfilled, onRejected, progressBack]);
if (this.$$state.status > 0) scheduleProcessQueue(this.$$state);
return result;
},
'catch': function(callback) {
return this.then(null, callback);
},
'finally': function(callback, progressBack) {
return this.then(function(value) {
return handleCallback(value, resolve, callback);
}, function(error) {
return handleCallback(error, reject, callback);
}, progressBack);
}
});
我在 SO 中进行了搜索,Google 搜索了一下,但我找不到任何相关的帖子或对我的问题的解释。大多数答案都与Ruby有关,或者反应:
Uncaught TypeError: Cannot read property 'state' of undefined
由于我不了解 AngularJS 和 bower 的全部功能,因此我不清楚这些答案。
你们能帮帮我吗?
提前致谢!
angular-busy
module 不是由 AngularJS 团队创建的。函数 addPromiseLikeThing
看起来很可疑,它是在进入 $q 库之前执行的最后一件事,它在那里爆炸了。使用 'promiseLike' 对象伪造 $q 库可能是错误的原因。
此外 AngularJS V1.6 更改了处理拒绝的方式。错误信息:
angular.js:14525 Possibly unhandled rejection: {"data":{"status":401,
是这些变化的结果。
有关详细信息,请参阅 AngularJS Developer Guide - Migrating to V1.6 ($q)