This example attempts to make synchronous code asynchronous. All the examples I found did the opposite, with the exception of the main first example in docs.angularjs.org .. $ q below.
The document contains the $ q constructor that I am trying to use. Unfortunately, the jsfiddle Angular 1.1.1 and 1.2.1 libraries provide a $ q object (not a function), as in this example. Instead, I should give my example and hope that someone sees a mistake.
https://docs.angularjs.org/api/ng/service/ $ q
I need to see that "this does not happen!" for execution.
f = function(name) {
return $q(function(resolve, reject) {
console.log "this does not happen!"
resolve('great')
});
}
f(name).then(function(result) {
console.log 'result', result
}, function(error) {
console.log 'error', error
});
Instead of registering, this does not happen! after which "excellent", I really see the function passed in $ q logged ::
result function(resolve, reject) {
console.log "this does not happen!"
resolve('great')
}
- , ?