i'm having a problem with my angular code.
I'm trying to filter and array using angular filter service but when i get to filtering the array in the filter it duplicates instead of taking each element in the array, i have tried track by but it does not seem to be working.
Here is my angular code:
.filter('priceRange', function() {
return function(arr, range) {
if (!range) {return arr; }
var priceResult = [];
var pRange = range.split('-');
angular.forEach(arr, function(key, index) {
if (key.pPice >= pRange[0] && key.Price <= pRange[1]) {
priceResult.push(key);
}
})
console.log(arr);
return priceResult;
}
})
Here is my html sep up:
<div class="col s12 m3" ng-repeat="car in [1,2,3,4,5] | priceRange" >
</div>
when i console.log the array in the filter section i get :
[1, 2, 3, 4, 5] rentTatu.js (line 66)
[1, 2, 3, 4, 5] rentTatu.js (line 66)
[1, 2, 3, 4, 5] rentTatu.js (line 66)
[1, 2, 3, 4, 5] rentTatu.js (line 66)
[1, 2, 3, 4, 5] rentTatu.js (line 66)
when i try that with a different array i still get duplicates of the array five tims