javascript - ng-repeat fails to execute correctly angularjs -


so i'm new angular , i'm trying take json collection obtained restful call , loop through each 1 display value while associating designated id in href.

below find have tried:

<div class="span2">         <!--sidebar content-->          search: <input ng-model="query">         sort by:         <select ng-model="orderprop">             <option value="name">alphabetical</option>             <!--option value="age">newest</option>             <option value="-age">oldest</option-->         </select>      </div>     <div class="span10">         <!--body content-->         <ul class="documents">             <li ng-repeat="document in documents | orderby:orderprop" class="thumbnail">                 <a href="#/rest/{{document.document_id}}">{{document.title}}</a>             </li>         </ul>         <pre>{{ documents | json }}</pre>     </div> 

the shttp call:

    function doclistctrl($scope, $http) {     console.log('getting documents data');     $http.get('/*restful call here*/').success(function(data)     {         $scope.documents = data;     });     $scope.orderprop = 'name'; } 

when run page list no problem using the

<pre>{{ documents | json }}</pre> 

but ng-repeat fails implement.

edit

here example of json working with.

{   "next": {},   "items": [     {       "document_id": 3177554002,       "title": "title of item"     } ] } 

what doing incorrectly ng-repeat call fails list data way wish?

thanks help

based on json, see ng-repeat isn't quite correct. need reference items array inside documents object when iterating, so:

<ul class="documents">     <li ng-repeat="document in documents.items | orderby:orderprop" class="thumbnail">         <a href="#/rest/{{document.document_id}}">{{document.title}}</a>     </li> </ul> 

or if want make simpler, bind data.items documents instead of data , keep existing template. ensure orderby keeps working.


Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -