ng-resource can handle objects as well as arrays.  It sounds like you are 
using the query() method or something that expects an array returned.  Per 
the docs there is an *isArray*
flag that can be set....


var Books =  $resource('/api/books')

var books = new Books();
books.$get(
  function (data){ //success callback
$scope.booksList = data.books; //just pass the array part to what you need 
to be an array 
  },
  function (data){ console.warn(data) } //error callback
)

<ul>
  <li ng-repeat="book in booksList">{{book.name}}</li>
</ul>

On Wednesday, February 12, 2014 7:46:49 AM UTC-7, Denis J. Cirulis wrote:
>
> Hello list,
>
> i have to consume rest service in my application and the output of 
> resource is "hashed" JSON (probably python-flask is behind the scenes).
> I can not use ng-resource in my factory because of the structure like:
>
> { 'books': [
>    { 'name':'1'},
>    { 'name':'2'},
>   ]
> }
>
> ng-resource expects to see [ {'name':'1'},{'name':'2'} ]
>
> How to overcome this ? Or maybe the correct way would be to use $http for 
> this kind of task ?
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to