-
I am trying to add a checkbox value in database and its work perfect.
-
The problem is if I need to check a checkbox after getting result from response its showing the checked value as -1 but i need a checkbox value as 0,1,2 etc.
-
If i click a checked box value its index value must be changed to -1 only but its changing as 0 or some other value
Below my code
HTML:
<div ng-repeat="tag in edit_tag_list">
<input type="checkbox" ng-model="tag.selected" id="{{tag.id}}" value="{{tag.id}}" ng-checked="selectionTagList.indexOf(tag.id) > -1" ng-click="toggleSelection(tag.id)" style="cursor: pointer;" ng-true-value="checked" ng-false-value="">
<input type="checkbox" ng-model="tag.selected" id="{{tag.id}}" value="{{tag.id}}" ng-checked="tag.checked='yes'" ng-click="toggleSelection(tag.id)" style="cursor: pointer;" ng-true-value="checked" ng-false-value="">
JS:
$scope.toggleSelection=function(tageName){
var idx=$scope.selectionTagList.indexOf(tageName);
if(idx > -1)
{
$scope.selectionTagList.splice(idx,1);
}
else
{
$scope.selectionTagList.push(tageName);
}
console.log($scope.selectionTagList);};
Aucun commentaire:
Enregistrer un commentaire