1
所以看起來我的要求:
angular.module('todoApp').factory('UsersService', ['$resource', 'paramsService', '$q', function($resource, paramsService, $q){
var server = paramsService.serverUrl;
return {
'auth': function(username, password){
var $response = {};
$resource(server + '/api/account/auth', {}, {call: {method: 'POST', headers: {'Content-Type': 'application/json'}}}).call(
{'username': username, 'password': password},
function(data){
console.log(data);
$response = data;
}
);
console.log($response);
return $response;
},
}
}]);
在數據成功功能我HAVA響應,但變量$迴應是空的。我知道,但爲什麼會發生,但無法找到方法等待響應返回它。我如何獲得$資源的迴應?
查看docs.angularjs網站上的教程示例。範圍項目接受承諾 – charlietfl 2013-04-10 14:13:36