Schauen Sie sich ohne weiteres den Beispielcode an
HTML -Code
<Th> <a href = "" ng-klick = "Desc ('2', la =! la)"> Einheitspreis </a> </th> <Th> <a href = "" ng-klick = "Desc ('3', la =! la)"> Verkaufsmenge </a> </th> <th> <a href = "ng-click =", ""-"ng-click =", "", "-" "ng-click =" "," "", "" ng-click = "", "", "", "" ng-klick = " Menge </a> </th> Wo wird la=!la verwendet, um festzustellen, ob der aktuelle Klick true oder false ist
JS -Code
//The default is to the totalnum field in descending order $scope.foodsale =ret.sort(function ( x,y ) { return y.totalnum - x.totalnum;//This means that the totalnum field in ret【represents the receiving and return array】 is arranged in descending order reversely. return x.totalnum - y.totalnum; in ascending order}) $scope.desc= function (fla,bol) { if(fla=="4"){ if(bol==false){ $scope.foodsale =$scope.foodsale.sort(function ( x,y ) { return y.totalnum - x.totalnum; }) }else{ console.log("bbb") $scope.foodsale =$scope.foodsale.sort(function ( x,y ) { return x.totalnum - y.totalnum; }) } }else if(fla=="3"){//totalmoney if(bol==false){ $scope.foodsale =$scope.foodsale.sort(function ( x,y ) { return y.totalmoney - X.Totalmoney; x, y) {return y.price - X.Price;Zusammenfassen
OK, das obige ist der gesamte Inhalt von AngularJs, das die Doppelklick-Sortierfunktion implementiert. Durch den obigen Beispielcode können Sie Doppelklicksortierungen erkennen. Ich hoffe, es wird für alle hilfreich sein, AngularJs zu lernen.