I created a working filter that filters the data by month.
A click on a month name shows correct data. I wonder how to show all data on page load. Actually, no data is shown on page load until I click a select a month.
PlasmaCrm.filter('triParMois', function() {
return function( items, mois ) {
var filtered = [];
angular.forEach(items, function(item) {
if(item.created_at.substring(5, 7) == mois) {
filtered.push(item);
}
});
return filtered;
};
});
I use this filter there:
<tr ng-repeat="finance in finances | triParMois:leMois">
And I set the value of leMois with a click on the motn name like this
<button ng-click="leMois = 01 ">Janvier</button >
How should I do?
If leMois is undefined at start you could do somthing like this:
PlasmaCrm.filter('triParMois', function() {
return function( items, mois ) {
var filtered = [];
angular.forEach(items, function(item) {
if(item.created_at.substring(5, 7) == mois || angular.isUndefined(mois)) {
filtered.push(item);
}
});
return filtered;
};
});
If it is null or some other value check for that instead.