Seeking guidance as a newcomer to Angular Material, I am trying to implement a date range filter for a table of N results. The options in the filter select are (1 day, 5 days, 1 week, 15 days), which are populated using a variable
JS
vm.rangos=[
{id:"1",name:'1 day',value:'1'},
{id:"2",name:'5 days',value:'5'},
{id:"3",name:'1 Week',value:'7'},
{id:"4",name:'15 days',value:'15'}
];
HTML
<div layout="row" flex="90" layout-align="start center">
<label flex="25">Range</label>
<select flex="60" ng-model="vm.rangoSelected" placeholder="" ng-options="ran.name for ran in vm.rangos" class="custom-select ">
</select>
</div>
I'm struggling with how to create the function to apply the filter and display results within the selected range
This function captures the value from the selection
function sendFilter(){
var filterSend = "";
switch(vm.filterSelected){
case 'range':
filterSend = vm.rangoSelected.value;
break;
default:
alert('not done');
break;
}
vm.showLastMovements(filterSend);
}
JSON
{
"result": {
"httpCode": 200,
"httpMessage": "OK",
"moreInformation": ""
},
"data": {
"movements": [
{
"operationDate": "2017-01-18",
"concept": "Decathlon",
"amount": "-450.0",
"currency": "EUR",
"balance": "29150.0",
"category": 1
},
{
"operationDate": "2017-01-18",
"concept": "Corte Ingles",
"amount": "-259.0",
"currency": "EUR",
"balance": "34000.0",
"category": 2
},
{
"operationDate": "2017-01-15",
"concept": "Carrefour",
"amount": "348.0",
"currency": "EUR",
"balance": "12000.0",
"category": 1
},
{
"operationDate": "2017-01-01",
"concept": "Corte Ingles",
"amount": "-259.0",
"currency": "EUR",
"balance": "34000.0",
"category": 2
},
{
"operationDate": "2016-12-30",
"concept": "Cortefiel",
"amount": "348.0",
"currency": "EUR",
"balance": "12000.0",
"category": 1
}
]
}
}
This function displays the selected value with an alert.
If you have any insights on creating this function or tips on how to proceed with displaying records based on the selection made, your assistance would be greatly appreciated.
Many thanks