I'm trying to figure out why my date range filter is not working and I get thrown the error - [$injector:unpr] Unknown provider: dateRangeProvider <- dateRange <- dashboardController. I tried putting the 'dateRange' in my dependencies and $filter, not sure if what I did was correct or not. Any help is definitely appreciated! Thanks!
My HTML that I am trying to filter between two dates to grab the id of the products
<input style="width:200px; padding:10px; border-radius:4px;"type="text" placeholder="search name" ng-model='productFilter'>
<input type="date" ng-model="to_date">
<input type="date" ng-model="from_date">
<div ng-repeat="product in products | dateRange : from_date : to_date | filter: productFilter track by $index">
<p>Total Inputs: {{product.createdAt}}{{product._id}}</p>
</div>
This is my DashboardController
app.controller('dashboardController', ['$scope', '$filter', 'OpFactory', function($scope, $filter, OpFactory){
function getProducts(){
OpFactory.getProducts(function(data){
$scope.products = data;
console.log("data from getProducts function in dashboardcontroller", data);
})
}
getProducts();
$filter('dateRange', function() {
return function( product, fromDate, toDate ) {
var filtered = [];
console.log(fromDate, toDate);
var from_date = Date.parse(fromDate);
var to_date = Date.parse(toDate);
angular.forEach(product, function(item) {
if(item.completed_date > from_date && product.completed_date < to_date) {
filtered.push(item);
}
});
return filtered;
};
});
}]);