javascript - Angular JSON Display Single Result without Ng-repeat Filter -
i'm still develop app show news update api json. now, load of data json. filter ng-repeat. problem because when load data, it's slow. many data.
i want make in controller, 1 row selected. so, can easyly load detail page.
i want order news desc. i've use | orderby. works. must load of data in 1 time. make apps slow. want make swipe refresh show 8 posts @ first time. but, load data when swipe (like twitter).
controller.php
.controller('mediactrl', function($scope, $http) { $http.get('http://api.pemiluapi.org/rekam-jejak-media/api/rekam_jejak?apikey=c6a0237499f3e4197546b5551a3a864f') .then(function(res){ $scope.medias = res.data; //alert(res.data); }); }) .controller('mediadetailctrl', function($scope, $stateparams, $http) { $http.get('http://api.pemiluapi.org/rekam-jejak-media/api/rekam_jejak?apikey=c6a0237499f3e4197546b5551a3a864f') .then(function(res){ $scope.medias = res.data; $scope.mediaid = $stateparams.mediaid; //alert(res.data); }); })
detail.html
<ion-content style="padding:30px;" class="item-remove-animate " ng-repeat="media in medias.data.results.rekam_jejak | filter: {id: mediaid}" type="item-text-wrap" href="#/tab/daerah/{{province.id}}">
media.html (all news)
<ion-item class="item-remove-animate " ng-repeat="media in medias.data.results.rekam_jejak | orderby:'id':true" type="item-text-wrap" href="#/tab/media-detail/{{media.id}}">
thanks in advance :) let share
are using ionic framework? ion-content directive in ionic framework. long list, better use collection repeat instead of ng-repeat.
code list items this
<ion-content> <ion-item collection-repeat="media in medias.data.results.rekam_jejak"> <a ng-href="#/{{media.url}}">{{media.id}}</a> <ion-item> </ion-content>
if click on link, should have route in config have own view(template) , controller. in view, should show particular item. don't think should have problem performance on detail page approach because there no need ng-repeat.
if have not understood problem, please let me know.
Comments
Post a Comment