1
Iam new to angularJS。嘗試瞭解更多關於$ resource和$ http方法的知識。無論我使用$ resource實現與服務器通信,在注入的初始點都會拋出異常。 ($ HTTP所有的動作都工作正常),如下圖所示
代碼:
'use strict';
angular.module('angularApp').constant("baseUrl", "http://localhost:3000/")
.factory('AccountFactory', ['$resource','baseUrl', function ($resource, baseUrl) {
var accountObj = {};
var accounts = $resource(baseUrl + "getAllAccounts",
{
userId: '@id'
}
);
accountObj.getAllAccounts = function() {
accounts.get(function (req) {
console.log("success");
}, function (req) {
console.log("failure");
});
}
return accountObj;
}]);
請糾正我,如果IAM做錯什麼在上面實現。
你的模塊中注入ngResource? –