This example is attempting to make synchronous code asynchronous. All examples I found were doing the opposite except the main first example at docs.angularjs.org .. $q below.
The doc lists a $q constructor which I am attempting to use. Unfortunately, the jsfiddle Angular libraries 1.1.1 and 1.2.1 provide a $q object (not a function) as in this example. Instead, I'll have to provide my example and hope that someone will see the bug.
https://docs.angularjs.org/api/ng/service/$q
I need to see "this does not happen!" line to execute.
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 logging "this does not happen!" followed by "great", I actually see the function passed to $q logged::
result function(resolve, reject) {
console.log "this does not happen!"
resolve('great')
}
Can someone see what I did wrong?