鍍金池/ 問答/HTML5/ angularjs 過濾器排序使用函數(shù),怎么用???

angularjs 過濾器排序使用函數(shù),怎么用?。?/h1>

圖片描述

這是 angularjs 手冊(cè) orderBy 解釋,哪位大神寫個(gè)例子,告訴一下 expression 為 function 函數(shù)時(shí)怎么用?。?/p>

回答
編輯回答
笨笨噠

終于摸索出答案了,自己回答吧,哈哈哈!

app.controller('ctl', function($scope){
    $scope.myOrder = function(item){
        return item.orderNum > 3: true: false;
    }
});

myOrder 返回 true,item往后排列,否則往前排。

2018年3月18日 00:20