angularjs - Order JSON data in Angular (Ionic) -


i need ordering json in ng-repeat. want order data item.id (from highest lowest). tried many tips on internet maybe i'm doing wrong because none of them working me... code:

$http.get('http://jastrzebieonline.pl/drogi/data/najnowsze.php')    .success(function(res){      $scope.news = res;      console.log("ok");     })    .error(function(data, status) {      console.log("error"); })  <div ng-repeat="item in news">     <a href="{{ item.id }}">       <img src="{{ item.image }}">       <h2>{{ item.title }}</h2>       <p>{{ item.date }}</p>       <p>{{ item.text }}</p>     </div>     </a>  </div> 

you can use orderby filter:

<div ng-repeat="item in news | orderby:'id'">     <a href="{{ item.id }}">       <img src="{{ item.image }}">       <h2>{{ item.title }}</h2>       <p>{{ item.date }}</p>       <p>{{ item.text }}</p>     </div>     </a>  </div> 

Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -