$q promises - Object is not a function
问题 I wanted to run the promises sample from https://docs.angularjs.org/api/ng/service/$q, here is my Code: angular.module('testControllers').controller('testCtrl', ['$scope', '$q', function($scope, $q) { function asyncGreet(name) { // perform some asynchronous operation, resolve or reject the promise when appropriate. return $q(function(resolve, reject) { setTimeout(function() { if (true) { resolve('Hello, ' + name + '!'); } else { reject('Greeting ' + name + ' is not allowed.'); } }, 1000); });