ItSolutionStuff.com

How to Get Selected Radio Button Value in AngularJS?

By Hardik Savani • October 20, 2023
Angular

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:

<!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 class="radio">

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

</div>

<div class="radio">

<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...

Tags: Angular
Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

AngularJS Convert String to Object Example

Read Now →

AngularJS Dynamically Change Image SRC on Click Example

Read Now →

AngularJS Filter Change Date Format in Controller Example

Read Now →

AngularJS Remove Duplicates Object from Array Example

Read Now →

AngularJS Check and Uncheck All Checkboxes Example

Read Now →

AngularJS Check Checkbox is Checked or Not Example

Read Now →

AngularJS Drag and Drop Table Rows Example with Demo

Read Now →

How to Copy to Clipboard without Flash in AngularJS?

Read Now →

AngularJS Convert Comma Separated String to Array Example

Read Now →

AngularJS Nl2br Filter for Textarea Content Example

Read Now →

How to Call AngularJS Controller Function in JQuery?

Read Now →

How to Hide Div After Some Time in AngularJS?

Read Now →

AngularJS Simple Datepicker Directive Example Tutorial

Read Now →

AngularJS - How to Limit String Length using Filter?

Read Now →