我是angularjs平台的新手,我面临的问题是解决我的雇主给出的一个小任务。我希望有一个人可以帮助我。angularjs比较运算符函数
我有一套员工表,我需要在ng-option中使用比较运算符,然后在数字字段中输入数字来获得结果。 (例如,如果用户选择大于ng选项并在文本字段中输入'50',结果应该从数据表中筛选出年龄大于50的年龄任何人都可以帮忙请参考!
这就是我试图
$scope.operators = [
{
field: "gt"
title: ">"
}
, {
field: "lt"
title: "<"
}
, {
field: "et"
title: "="
}
];
$scope.selected = $scope.operators[0];
app.filter('priceGreaterThan', function() {
return function (input, price) {
var output = [];
if (isNaN(price)) {
output = input;
}
else {
angular.forEach(input, function (item) {
if (item.redemptions > price) {
output.push(item)
}
});
}
return output;
}
});
感谢那仁先生。在我的函数中,我不知道如何从ng选项中获取选定的值。这是我的问题 –