Update value in scope from click event
Description
The following code shows how to update value in scope from click event.
Example
<!doctype html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.js"></script>
<script type='text/javascript'>
function Ctrl($scope) {<!-- ww w .j a v a2 s. c o m-->
$scope.value1 = true;
$scope.value2 = "YES";
$scope.value1Clicked = function() {
($scope.value1) ? $scope.value2 = "YES" : $scope.value2 = "NO";
}
}
</script>
</head>
<body>
<div ng-app>
<div ng-controller="Ctrl">
Value1: <input type="checkbox" ng-model="value1" ng-click="value1Clicked()"> <br/>
Value2: <input type="checkbox" ng-model="value2"
ng-true-value="YES" ng-false-value="NO"> <br/>
<tt>value1 = {{value1}}</tt><br/>
<tt>value2 = {{value2}}</tt><br/>
</div>
</div>
</body>
</html>