【发布时间】:2014-08-26 10:46:54
【问题描述】:
我创建了一个自定义方法更新,方法类型为 put。
我想抓住成功并在那里触发一些事件。
有人知道怎么做吗?
服务
(function () {
'use strict';
// this function is strict...
angular
.module('zdma.organization.services', [])
.factory('Organization', function($resource, Config) {
var Organization = $resource(
Config.url.organization + '/:id',
{
id: '@id'
},
{
'update': {
method: 'PUT'
}
}
);
// class methods
Organization.getEmptyOrganizationTemplate = function () {
return {
'id': '',
'name': '',
'declarationCode': '',
'website': ''
};
};
return Organization;
});
}());
在控制器中
angular
.module('zdma.organization.controllers', [])
.controller('OrganizationCreateCtrl', function($scope, $location, Organization) {
function init() {
$scope.organization = new Organization(Organization.getEmptyOrganizationTemplate());
}
$scope.save = function() {
$scope.organization.$save();
};
init();
});
你能帮我在这种情况下怎么做吗?
请假设我的模型基于视图更新
【问题讨论】:
标签: angularjs put ngresource