Is it possible to trigger the updateRow method on every change of a radio button selection?
Currently, the updateRow method is only being called the first time the radio button changes. How can I make sure it executes each time there is a change?
Html:
<div ng-repeat="b in RS_BehaviorActions">
<input id="{{b.name}}" type="radio" name="behavior" value="{{b.name}}" style="padding:10px;" ng-model="selBehaviorVal" ng-change="updateRow(obj, selBehaviorVal)" /><label>{{b.name}}</label>
</div>
js:
// Call updateRow method and push radio button value into JSON on change
$scope.updateRow = function (obj, selectedItem) {
$scope.selectedItem = selectedItem;
$scope.existInArray = false;
for (var i = 0; i < $scope.permissionArray.length; i++) {
if ($scope.permissionArray[i].relationShip == $scope.relationShip) {
$scope.existInArray = true;
break;
}
}
if ($scope.existInArray) {
for (var i = 0; i < $scope.permissionArray.length; i++) {
if ($scope.permissionArray[i].relationShip == $scope.relationShip) {
index = i;
break;
}
}
//$scope.permissionArray.splice(index, 1);
$scope.permissionArray[index].behavior = $scope.selectedItem;
}
else {
$scope.permissionArray.push({ "relationShip": $scope.relationShip, "behavior": $scope.selectedItem });
}
console.log($scope.permissionArray);
}