0
var customersApp = angular.module('customersApp', ['ngGrid']);
var url = 'api/Customer';
//the factory object for the webAPI call.
customersApp.factory('customerRepository', function ($http) {
return {
insertUser: function (callback,user) {
var user = { "id": user.id, "city": user.city, "name": user.name, "address": user.address, "contactNo": user.contactNo, "emailId": user.emailId };
$http.post(url, user).success(callback);
}
});
控制器是
customersApp.controller('customerCtrl', function ($scope, customerRepository) {
customerRepository.insertUser(function() {
alert('customer inserted successfully');
}, $scope.New)
});
我所試圖做的是改變$ HTTP到$的工廠資源這樣
customersApp.factory('customerRepository', function($resource){
return
$resource(url, { id: '@id' }, { update: { method: 'POST', } })
}
我的問題是,當我從$ http更改爲$資源時,我在哪裏放置使用工廠insertUser中的「用戶」數據。
請讓我知道$資源在工廠我在哪裏插入「用戶」數據。由於