myApp.controller("MyCtrl",function ($scope) {
$scope.value1= '0';
$scope.$watch('value1', function(value) {
alert(value);
});
});
JS Code:
var myApp = angular.module('myApp',[]);
function MyCtrl($scope) {
$scope.value1= '0';
$scope.$watch('value1', function(value) {
alert(value);
});
}
HTML Code:
<div ng-controller="MyCtrl">
<span ng-repeat="i in [0, 1, 2]">
<input name="asdf" ng-model="value1" value="{{i}}" type="radio">
</span>
<hr>
{{value1}}
</div>
Alert shown on loading only. After that value1 showing initial value only i.e 0.