【发布时间】:2016-05-11 15:26:40
【问题描述】:
我正在使用restangular,但“Put”方法有问题,它没有按预期工作
我的 angularService 代码
var userService = function (restangular) {
var resourceBase = restangular.all("account/");
restangular.addResponseInterceptor(function (data, operation, what, url, response, deferred) {
if (operation == "getList") {
return response.data;
}
return response;
});
this.getUserById = function (id) {
return resourceBase.get(id);
// return restangular.one("account", id).get();
};
this.updateUser = function(user) {
return user.Put();
};
}
我的控制器代码
var userEditController = function (scope, userService, feedBackFactory, $routeParams) {
scope.user = undefined;
scope.updateUser = function () {
userService.updateUser(scope.user).then(function (data) {
feedBackFactory.showFeedBack(data);
}, function (err) {
feedBackFactory.showFeedBack(err);
});
};
userService.getUserById($routeParams.id).then(function (data) {
scope.user = data.data; **// Please not here I am reading the object using service and this object is getting updated and pass again to the service for updating**
}, function (er) {
feedBackFactory.showFeedBack(er);
});
};
但我收到错误“Put”不是函数,我检查了用户对象,发现用户对象没有重新调整角度(没有找到任何其他方法)。我该如何解决它
【问题讨论】:
标签: javascript angularjs restangular