I am trying to update my object with the code below:
$scope.saveShop = function(data, s) {
if (!s.id) {
var shop = new Shops(data);
shop.$save(function(data){
s.id = data.id;
return true;
})
} else {
Shops.get({
shopId: s.id
}, function(shop) {
shop.name = "fsdfjı324h9fhfhhf34fh34";
shop.updatedAt = new Date().getTime();
shop.$update(function() {
return true;
});
});
}
};
But data is not updated in the database. Where am I wrong?
UPDATE: also I have a custom service:
angular.module('mean.shops').factory("Shops", ['$resource', function($resource) {
return $resource('shops/:shopId', {
shopId: '@id'
}, {
update: {
method: 'PUT'
}
});
}]);
This also doesn't work.