Here is an interesting question that I have encountered. I created a drop box list using ng-repeat. Take a look at the code below:
<ul>
<li ng-repeat="item in formLIST.ContractType">
<input type="checkbox" ng-click="checkItems(item)" value={{item.ls_ItemIndex}} >{{item.ls_ItemValue}}
</li>
</ul>
This is my AngularJS code snippet:
$scope.listitem=[];
$scope.checkItems = function (item) {
$scope.listitem.push({
item: item.ls_ItemValue
});
I have a query regarding this setup: I would like to know how to ensure that when the checkboxes are checked or unchecked, it correctly adds or removes the corresponding value in my JSON file.
Currently, clicking on the checkboxes results in adding them to my JSON file. However, if I uncheck and check them again, they get added multiple times without being removed. My goal is to add these values only once.