zoukankan      html  css  js  c++  java
  • 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; }; }]);

  • 相关阅读:
    Ubuntu 16.04 设置静态IP 注意事项
    C++ Primer: 1. 初识输入和输出
    车牌识别1:License Plate Detection and Recognition in Unconstrained Scenarios阅读笔记
    梳理检测论文-Refinement Neural Network
    linux 的 磁盘管理
    ubuntu 18 设置语言环境
    Ubuntu 18.04 的网络配置
    YoLo 实践(1)
    Distributed TensorFlow
    MXNet 分布式环境部署
  • 原文地址:https://www.cnblogs.com/yiyangl/p/10107256.html
Copyright © 2011-2022 走看看