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

Popular posts from this blog

node.js - How to mock a third-party api calls in the backend -

node.js - Why do I get "SOCKS connection failed. Connection not allowed by ruleset" for some .onion sites? -

matlab - 0-by-1 sym - What do I need to change in order to get proper symbolic results? -