从 Angular 1.2.18 迁移到 1.4x 时 $q 服务的变化

Changes in $q service when migrating from Angular 1.2.18 to 1.4x

我正在将 angular 版本 1.2.4 迁移到 1。4x.But 我在 $q 服务中遇到问题。 下面是我的代码:

版本 1.2x

var deferred=$q.defer();

其中 deferred.promise 包含以下函数对象: catchfinallythen 在 1.4x 版本中,这已更改为 $$state 如果有人遇到类似的问题 issue.Please 分享您的想法..

版本 1.3.0-beta.18 中进行了性能改进。

commit responsible有如下描述:

perf($q): move Deferred and Promise methods to prototypes
NOTE: Deferred doesn't get all the advantages of moving methods to the prototype, since the constructor binds instance methods to "this" to support unbounded execution.

Closes #8300

这是为了提高性能,因为 class 的所有实例共享相同的原型,而如果您将它们作为每个实例的属性,浏览器必须为每个实例的函数分配内存,不止一次

我刚刚查看了deferred属性,它仍然具有catchfinallythen三个功能。 state 是一个 属性。当我检查对象层次结构时,这些方法现在似乎是在原型上定义的。