[英]Angularjs & restangular: how to use complicated routes
在我的应用程序中,对于一个基本模型,我得到了数据,因此:
var baseAccounts = Restangular.all('accounts');
baseAccounts.getList().then(function(accounts) {
$scope.allAccounts = accounts;
});
var newAccount = {name: "Gonto's account"};
然后我发送帖子请求:
baseAccounts.post(newAccount);
但是在我的应用程序中我也有这样的路线:
/accounts/batchimport
我如何将newAccount对象发送到model-url: accounts/batchimport
?
可能吗? 如何?
Restangular具有一组自定义方法 。
可用于发出自定义请求,例如:
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
希望它会有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.