Anshul Singh Panwar Anshul Singh Panwar - 1 year ago 75
AngularJS Question

AngularJs how to call the value of a radio button?

<div class="form-group">
<label class="control-label col-sm-2" for="pwd">Glossy: </label>
<div class="checkbox">
<label><input type="checkbox" value="">Yes</label>
<label><input type="checkbox" value="">No</label>

<div class="form-group">
<div class="col-sm-offset-2 col-sm-4">
<button type="submit" class="btn btn-default">Submit</button>

//document.getElementById("date").innerHTML = new Date();
var app = angular.module("myApp",[]);
app.controller("verify", function ($scope){

var verifydate = function(){
var name = $;
z = Date.parse(Date());
z = z + 86400000;
var mydate1 = new Date(z);


`How do you call the value of a radio button in angularJS and store it in a variable. I am trying to make this function in the controller so that i can print the delivery date in the span but I am not able to?

enter image description here

Answer Source

You can find all the necessary information in the documentation for input\[radio\]

Every input should have the same ng-model but with different value or ng-value

var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
  $scope.shirts = "A magnificient t-shirt with a unicorn on it !";//used with ng-value
<script src=""></script>
<div ng-app="myApp" ng-controller="myCtrl">
  <input type="radio" id="poster" name="optradio" ng-model="option" value="poster">Posters
  <input type="radio" id="coffee" name="optradio" ng-model="option" value="coffee">Coffee mugs
  <input type="radio" id="shirt" name="optradio" ng-model="option" ng-value="shirts">T-shirts

  <p>You choosed : {{option}}</p>

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download