mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-23 19:40:56 +08:00
chore($q): replace plain TypeError with minErr+TypeError in cyclical resolve check
This commit is contained in:
23
docs/content/error/$q/qcycle.ngdoc
Normal file
23
docs/content/error/$q/qcycle.ngdoc
Normal file
@@ -0,0 +1,23 @@
|
||||
@ngdoc error
|
||||
@name $q:qcycle
|
||||
@fullName Cannot resolve a promise with itself
|
||||
@description
|
||||
|
||||
Occurs when resolving a promise with itself as the value, including returning the promise in a
|
||||
function passed to `then`. The A+ 1.1 spec mandates that this behavior throw a TypeError.
|
||||
https://github.com/promises-aplus/promises-spec#the-promise-resolution-procedure
|
||||
|
||||
```
|
||||
var promise = $q.defer().promise;
|
||||
|
||||
//bad
|
||||
promise.then(function (val) {
|
||||
//Cannot return self
|
||||
return promise;
|
||||
});
|
||||
|
||||
//good
|
||||
promise.then(function (val) {
|
||||
return 'some other value';
|
||||
});
|
||||
```
|
||||
Reference in New Issue
Block a user