How to get selected radio button value in AngularJS?

How to get selected radio button value in AngularJS?

In this post we will give you information about How to get selected radio button value in AngularJS?. Hear we will give you detail about How to get selected radio button value in AngularJS?And how to use it also give you demo for it if it is necessary.

In this example, i will help to get checked radio button value in angular js app. we can get selected radio button value in controller of angular.

Here we will create simple example. we will create simple for and submit button. When you click on submit button then one angular controller method will call and we will get selected radio button value using angularjs $scope variable.

Let’s see bellow example, so you can use in your app.

Example:

Also see:How to get Current Date and Time in AngularJS?

<!doctype html>

<html>

<head>

<title>How to get selected radio button value in AngularJS? - ItSolutionStuff.com</title>

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>

</head>

<body ng-app='myapp'>

<h1>How to get selected radio button value in AngularJS? - ItSolutionStuff.com</h1>

<div ng-controller="myCtrl">

<div >

<label><input type="radio" ng-model='sex' ng-value='"male"' name="sex">Male</label>

</div>

<div >

<label><input type="radio" ng-model='sex' ng-value='"female"' name="sex">Female</label>

</div>

<button ng-click="submitResult()">See Result</button>

</div>

</body>

<script type="text/javascript">

var app = angular.module('myapp', []);

app.controller('myCtrl', function ($scope, $location) {

$scope.sex = 'male';

$scope.submitResult = function() {

alert($scope.sex);

};

});

</script>

</html>

I hope it can help you…

Hope this code and post will helped you for implement How to get selected radio button value in AngularJS?. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Leave a Comment

Your email address will not be published. Required fields are marked *

36  +    =  38

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US