Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$object empty #1279

Open
m33ch opened this issue Dec 12, 2015 · 2 comments
Open

$object empty #1279

m33ch opened this issue Dec 12, 2015 · 2 comments

Comments

@m33ch
Copy link

m33ch commented Dec 12, 2015

Hi,

thank you for this package! It's awesome!!

I read this part of documentation so i tried to do something like this :

service

(function() {
    "use strict";

    angular.module('app.services').service('MyService', function($rootScope, Restangular) {
        
        var _resources = Restangular.all('resources');

        this.list = function(data) {
            return _resources.getList(data);
        };      
    });

})();

controller

(function(){
    "use strict";

    angular.module('app.controllers').controller('MyCtrl', function($scope, MyService){

        $scope.todos = MyService.list().$object;
    });

})();

And in my piece of view

   <tr ng-repeat="todo in todos">
        <td>{{todo.name}}</td>
        <td>{{todo.description}}</td>
        <td>{{todo.value}}</td>
        <td>{{todo.type}}</td>
        <td>{{todo.status}}</td>
</tr>

The problem is that todos is empty!
Why is that the problem?

Thank you very much!

@Jorgen-VikingGod
Copy link

I have the same issue on my app.
The node.js server returns the values correctly (tested by Postman)
but on the webservice Restangular only can get single values by

Restangular.one('todo', '56910eb66e4c52ac7c5132a4').get().then(function(data) {
   console.log(JSON.stringify(data, null, 2));
});

but this code below has no entries (on AngularJS side - but node.js send the data out):

$scope.todos = Restangular.all('todo').getList().$object;
console.log(JSON.stringify($scope.todos, null, 2));

@daviesgeek
Copy link
Collaborator

Can you provide a working example on Plunker please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants