我正在使用http://vitalets.github.io/angular-xeditable/并查看它们的jsfiddle中的表:http://jsfiddle.net/NfPcH/93/
$scope.saveUser = function(data, id) {
//$scope.user not updated yet
angular.extend(data, {id: id});
return $http.post('/saveUser', data);
};我想要改变这样一个事实,即本地模型仅在保存到远程服务成功后才被持久化/更新。
1)我如何做到这一点?
2)另外,是否可以将onbeforesave应用于下拉菜单/select?
发布于 2014-10-02 10:30:03
我认为您可以在请求返回promise之后进行更新。
$scope.saveUser = function(data,id){
angular.extend(data, {id: id});
$http.post('/saveUser', data)
.then(
//callback function for success save to server
function(response){
//do any of your update here
$scope.item = data.item;
},
//else handle your error here
function(error){
console.log(error)
}
);https://stackoverflow.com/questions/26151562
复制相似问题