Sto usando restangular, ma ho un problema con il metodo "put", il suo non funziona come previstoCome utilizzare il metodo PUT in restangular
Il mio codice 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();
};
}
Il mio codice di controllo
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);
});
};
ma sto ricevendo un errore "Put" non è una funzione, ho controllato l'oggetto utente e ho trovato che l'oggetto utente non è restangularizzato (nessun metodo aggiuntivo per und). Come posso risolverlo
Come hai fatto sapere che il tipo è 'utente'? per esempio, ottengo 'http: // localhost: 8100/api/undefined' quando si usa il metodo' copy() '. Il 'undefined' dovrebbe essere l'oggetto' utente'. Come farlo bene? Grazie! –