How to order ng-repeat with a function a use button to change the order parameter in angularjs -
i have little bug while trying use angularjs table.
tr th a(href='', ng-click="predicate = 'id'; reverse=!reverse") id th a(href='', ng-click="predicate = 'number'; reverse=!reverse") th a(href='', ng-click="predicate ='urlglobalcount'; reverse=!reverse") total tr(ng-repeat='url in urllist | orderby:predicate:reverse' ng-init="addone(url)") td {{$index + 1}} td {{url.number}} td {{urlglobalcount(url)}}
the funtion urlglobalcount return number
$scope.urlglobalcount = function(item) { return *somenumber* };
when try order urlglobalcount it's not working.
if change code :
tr(ng-repeat='url in urllist | orderby:urlglobalcount :reverse' ng-init="addone(url)")
ordering urlglobalcount function work fine.
any idea fix ?
assign actual function in click, not string of function. change:
ng-click="predicate ='urlglobalcount';
to:
ng-click="predicate =urlglobalcount;
Comments
Post a Comment