2016-05-01 1 views
0

を使用するには:Angularjs&restangular:どのように私は、データを取得する1つの基本モデルのために、私のアプリでは、複雑なルートに

var baseAccounts = Restangular.all('accounts'); 

baseAccounts.getList().then(function(accounts) { 
    $scope.allAccounts = accounts; 
}); 

var newAccount = {name: "Gonto's account"}; 

し、私は、POSTリクエストの送信:

baseAccounts.post(newAccount); 

しかし、私のアプリではまた、私は、このようなルートを持っている:

/accounts/batchimport 

どのように私は、モデルのURLに私のnewAccountオブジェクトを送信することができますaccounts/batchimport

は可能ですか? とはどのようにですか?

答えて

0

矩形はcustom methodsのセットです。同様に、カスタム要求を行うために使用することができ

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 

はそれに役立つことを願っています。

関連する問題