Reputation: 484
I have a simple filter that puts one of two statements, based on if a input from SQL is true
app.filter('yesNo', function() {
return function(input) {
return (input == '1') ? 'Skal tjekkes!' : 'Alt OK';
}
});
And then should change a menu item based on that;
<li role="presentation"><a href="#" data-ng-click="statusFilter = 'Ny ordre'">New Orders
<div ng-if="input == '1' | outdated">
<p>Needs to be checked: {{(orders | filter:{status:'ny ordre', outdated: '1'}).length}}</p>
</div>
<div ng-if="!input == '1' | outdated">Shows regardless</div>
</a></li>
I am missing something, just no idea what. :(
Upvotes: 0
Views: 66
Reputation: 11
You have an example here for how to use a custom filter function: http://jsfiddle.net/alexdumitrescu/zv6cf7nq/
var myApp = angular.module('myApp', [])
.filter('myfilter', function() {
return function(orders) {
return orders.filter(function(order) {
return order.outdated == '1';
})
}
});
function MyCtrl($scope) {
$scope.orders = [{
status: 'my order1',
outdated: '1'
}, {
status: 'my order2',
outdated: '0'
}];
}
<div ng-controller="MyCtrl">
{{orders | myfilter}}
</div>
Upvotes: 1