我正在尝试使用具有多个数字列的 angular-smart-table 创建一个表。我必须对所有这些实施范围搜索。我创建了一个指令和一个自定义过滤器来过滤数据。我可以为单列实现它,但是当我多次使用同一指令时,范围搜索将停止工作。面临的问题在下面提到
我已经创建了一个plunk类似于要求。请帮忙!
myApp.directive('stNumberRange', ['$timeout', function ($timeout) {
return {
restrict: 'E',
require: '^stTable',
scope: {
lower: '=',
higher: '='
},
template: '<input type="number" class="form-control input-sm" ng-change="rangeChanged()" step="0.01" ng-model="higher"/><input class="form-control input-sm" ng-change="rangeChanged()" type="number" step="0.01" ng-model="lower"/>',
link: function (scope, element, attr, table) {
var predicateName = attr.predicate;
scope.rangeChanged = function () {
var query = {};
if (scope.lower) {
query.lower = scope.lower;
}
if (scope.higher) {
query.higher = scope.higher;
}
table.search(query, predicateName)
}
}
};
}]);