This is the example to handle radio button in the angular JS forms
<!DOCTYPE html>
<html>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<body ng-app="user_registration">
<p>My Radio:</p>
<form ng-submit="submitForm()" ng-controller="coast">
<input type="radio" ng-model="gender" value="Male">Male<br>
<input type="radio" ng-model="gender" value="FeMale">Female<br>
<input type="radio" ng-model="gender" value="Other">Other<br>
<input type="submit" value="Register"/>
</form>
<script>
var app=angular.module('user_registration',[]);
app.controller('coast',function($scope){
$scope.submitForm = function(){
alert($scope.gender);
}
});
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<body ng-app="user_registration">
<p>My Radio:</p>
<form ng-submit="submitForm()" ng-controller="coast">
<input type="radio" ng-model="gender" value="Male">Male<br>
<input type="radio" ng-model="gender" value="FeMale">Female<br>
<input type="radio" ng-model="gender" value="Other">Other<br>
<input type="submit" value="Register"/>
</form>
<script>
var app=angular.module('user_registration',[]);
app.controller('coast',function($scope){
$scope.submitForm = function(){
alert($scope.gender);
}
});
</script>
</body>
</html>
Demo
My Radio:
0 comments:
Post a Comment