I've been working on creating a case-sensitive filter in an Angular controller to filter an array.
Here is the data:
var stoneArr =
[
{
"stone_name": "Diamond",
"id": 16
},
{
"stone_name": "Ruby",
"id": 17
},
{
"stone_name": "Sapphire",
"id": 18
},
{
"stone_name": "Emerald",
"id": 19
}
];
The HTML input is:
<input type="text" name="stone_name" class="form-control" id="stone_name"
ng-model="propertyName" maxlength="15" required>
The filter in the controller is as follows:
var stoneObj = $filter('filter')(stoneArr, {stone_name:$scope.propertyName}, true);
However, when entering "diamond" in the input field
$scope.propertyName = "diamond";
the filter does not match this string with "Diamond".
I need to keep the exact match condition (true) but also want to match the exact string without removing it. Using loops for such large arrays is not feasible. Is there a way to achieve this?