javascript - How to sort this object by name in angular -


my client needs angular js app, app based on api, of app that's running. 1 of apis, returns json structured this:

{      "groups":{         "60":{            "name":"history"       },       "74":{            "name":"discover our offers"       },       "109":{            "name":"relaxing"       }    } } 

so fetched data on controller way:

  $http({method: 'get', url: resturl}).       then(function(response)       {           $scope.poi_groups = response.data.groups;       }); 

and display on view:

<ul class="content-menu">     <li ng-repeat="(key, value) in poi_groups">         <div><a ng-href="/poi/data/{{ key }}">{{ value.name }}</a></div>     </li> </ul> 

what i've been struggling ordering items name, right being displayed way returned on json. how can like:

(...) <li ng-repeat="(key, value) in poi_groups | orderby: value.name"> (...) 

this structure isn't appropriate angularjs, either :

  1. do in .then method
  2. write own filter
  3. map object in new 1 in .then method make :

    [{ value:'60', name:'history' }, { .... }]

then can use angular filtering.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -