• smart-table 数值筛选


    HTML
    1
    <st-number-range predicate="balance" lower="balance.lower" higher="balance.higher"></st-number-range>
     配置
    1
    app.directive('stNumberRange', ['$timeout', function ($timeout) { 2 return { 3 restrict: 'E', 4 require: '^stTable', 5 scope: { 6 lower: '=', 7 higher: '=' 8 }, 9 templateUrl: 'stNumberRange.html', 10 link: function (scope, element, attr, table) { 11 console.log(element) 12 var inputs = element.find('input'); 13 var inputLower = angular.element(inputs[0]); 14 var inputHigher = angular.element(inputs[1]); 15 var predicateName = attr.predicate; 16 [inputLower, inputHigher].forEach(function (input, index) { 17 18 //红色为官方示例错误 19 input.bind('input', function () { 20 var query = {}; 21 22 if (scope.lower) { 23 query.lower = scope.lower; 24 } 25 26 if (scope.higher) { 27 query.higher = scope.higher; 28 } 29 30 scope.$apply(function () { 31 table.search(query, predicateName) 32 }); 33 }); 34 }); 35 } 36 }; 37 }])
    app.filter('customFilter', ['$filter', function($filter) {
                var filterFilter = $filter('filter');
                var standardComparator = function standardComparator(obj, text) {
                    text = ('' + text).toLowerCase();
                    return ('' + obj).toLowerCase().indexOf(text) > -1;
                };
    
                return function customFilter(array, expression) {
                    function customComparator(actual, expected) {
    
                        var isBeforeActivated = expected.before;
                        var isAfterActivated = expected.after;
                        var isLower = expected.lower;
                        var isHigher = expected.higher;
                        var higherLimit;
                        var lowerLimit;
    
                        if (angular.isObject(expected)) {
    
                            if (isLower || isHigher) {
                                //number range
                                if (isLower) {
                                    higherLimit = expected.lower;
                       //红色官方示例错误
                                    if (actual < higherLimit) {
                                        return false;
                                    }
                                }
    
                                if (isHigher) {
                                    lowerLimit = expected.higher;
                       //红色官方示例错误 
    if (actual > lowerLimit) { return false; } } return true; } //etc return true; } return standardComparator(actual, expected); } var output = filterFilter(array, expression, customComparator); return output; }; }]);

  • 相关阅读:
    61031145 ERROR
    插入IO寄存器和位置约束---lattice&diamond
    lattice简单时序报告---timing report
    自动化仿真模型的搭建---基于lattice DO文件和modelsim脚本
    IIC加载以及存在的问题---lattice XO3
    DUALBOOT(双启动) 调试
    jtag管脚复用---lattice LCMXO3
    flask学习笔记-10:留言板(三)
    #flask学习笔记-09:留言板(二)
    #flask学习笔记-08:留言板(一)
  • 原文地址:https://www.cnblogs.com/yiyangl/p/10107256.html
Copyright © 2020-2023  润新知