I am currently working with the following model in JavaScript and utilizing AngularJS:
$scope.data = {
FocusOn: " ",
Filters: [],
Range: {
From: "",
To: ""
}
}
Additionally, I have the following function defined:
$scope.addField = function ($type, $value) {
$scope.data1 = {
FilterName: $type,
FilterValue: $value
};
if ($scope.data.Filters[$type] === undefined) {
$scope.data.Filters.push($scope.data1);
}
$scope.data1 = "";
$scope.Json = angular.toJson($scope.data);
};
I am trying to add items to the Filters array only if they are not already present. Can anyone provide assistance on how to achieve this?
I attempted the above approach but encountered issues. Any help would be greatly appreciated.
Thank you.