Prev Demo
AngularJS
>
Radio Buttons
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>Demo</title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script> </head> <body> <script> var app = angular.module("app", []); app.controller("RadioController", function ($scope) { $scope.Gender = "Male"; $scope.RadioChange = function (s) { $scope.GenderSelected = s; }; }); </script> <div ng-app="app" ng-controller="RadioController"> Select gender <label><input type="radio" name="SGender" ng-change="RadioChange('Male')" ng-model="Gender" value="Male" /> Male </label> <label><input type="radio" name="SGender" ng-change="RadioChange('Female')" ng-model="Gender" value="Female" /> Female </label> <p> Selected gender: {{ Gender }} </p> <p> You have clikced on <b>{{GenderSelected}}</b> </p> </div> </body> </html>
Note: We DO NOT save your trial code in our database.
Output