Restangular – getList in response

Issue

can you say me what I am do wrong ?

var api = Restangular.all('person');
api.getList().then(function(data) {
    angular.forEach(data, function(val,key) {
       val.getList('role').then(function(res) {
           //...
       });
 });});

I want call /person/:id/role , but now call /person/role

Thanks for any advice

Solution

Thanks @min che , now is working good.

Solution: in angular.run()

Restangular.configuration.getIdFromElem = function(elem) {
        // if route is person ==> returns idPerson
        return elem["id"+elem.route.charAt(0).toUpperCase() + elem.route.slice(1)];
    }

Code on restangular page -> here … which use RestangularProvider in angular.config() not working for me

Answered By – Leopold Podmolík

Answer Checked By – Clifford M. (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.