Issue
In my app, for one basic model i get data so:
var baseAccounts = Restangular.all('accounts');
baseAccounts.getList().then(function(accounts) {
$scope.allAccounts = accounts;
});
var newAccount = {name: "Gonto's account"};
and then i send post request:
baseAccounts.post(newAccount);
But in my app also i have such route:
/accounts/batchimport
how can i send my newAccount object to model-url: accounts/batchimport
?
is it possible?
and how?
Solution
Restangular has a set of custom methods.
which could be used to make a custom requests, like:
var baseAccounts = Restangular.all('accounts');
baseAccounts.getList().then(function(accounts) {
$scope.allAccounts = accounts;
});
var newAccount = {name: "Gonto's account"};
baseAccounts.customPost(newAccount, "batchimport"); // it will call the accounts/batchimport
Hope it will help.
Answered By – MaKCbIMKo
Answer Checked By – Robin (AngularFixing Admin)