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
Post a Comment