Now i am creating one service like that :
angular.module('test')
.factory('AccountResource', function Account(Restangular) {
return Restangular.service('accounts');
});
and now the path is /accounts so i just inject that service into one of my controller
.controller('ProfileChangePasswordFormController', function ($scope, AccountResource) {
$scope.changePassword = function(){
console.log("change passord send request " );
console.log($scope.password);
AccountResource.post("chage_password",$scope.password).then(function() {
console.log("Object saved OK");
}, function() {
console.log("There was an error saving");
});
};
}
As you can see my rest resource that change password is under /accounts/change_password . But i not to know how add /change_password into existed restangular service ?
You can modify your factory to something like below
angular.module('test')
.factory('AccountResource', function Account(Restangular) {
function accounts(){
return Restangular.service('accounts');
}
function changePassword(){
return Restangular.service('change_password');
}
return {
accounts:accounts,
changePassword:changePassword
}
});
and in your controller you can use it
AccountResource.changePassword.post("chage_password",$scope.password).then(function() {
console.log("Object saved OK");
}, function() {
console.log("There was an error saving");
});