I am trying to make a filter in an angular controller that is case sensitive when filtering an array.
My data is as follows:
var stoneArr = [ { "stone_name": "Diamond", "id": 16 }, { "stone_name": "Ruby", "id": 17 }, { "stone_name": "Sapphire", "id": 18 }, { "stone_name": "Emerald", "id": 19 } ];
My HTML input is as follows:
<input type="text" name="stone_name" class="form-control" id="stone_name" ng-model="propertyName" maxlength="15" required>
My filter in the controller:
var stoneObj = $filter('filter')(stoneArr, {stone_name:$scope.propertyName}, true);
The trap here is that when I enter a βdiamondβ in the input field
$scope.propertyName = "diamond";
the filter does not match this line with "Diamond".
I do not want to remove the exact matching condition (true) from the equation, as shown below:
var stoneObj = $filter('filter')(stoneArr, {stone_name:$scope.propertyName});
This will not work for me, because I want to combine the exact string to filter the data. And the data will have unique values ββof "stone_name". Also, I do not want to use any loops, since the length of the array will exceed 1000+. Anyway, can I achieve this?