Just starting out with AngularJS and I've been given a small task to solve by my employer. Having some trouble with it, so hoping someone can lend a hand.
The task involves using comparison operators in ng-options along with a number field to filter results from a table of employees. For example, if the user selects 'greater than' in the ng-option and inputs '50' in the text field, the result should display employees whose age is greater than 50 from the data table. Any help would be greatly appreciated!
This is what I've attempted:
$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;
}
});