Ng-Value-3

 

In this example selected car with ng-value directive bind to the my.favorite and displayed below it when you select the car.

 
 
 
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Welcome to LearnKode - A code learning platform</title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"></script> </head> <body ng-app="app"> <h3>Which is your favorite ?</h3> <div ng-controller="controllerName"> <label ng-repeat="car in cars"> <input type="radio" ng-model="my.favorite" ng-value="car">{{car}} </label> <pre> Your Favourite Car is: = {{my.favorite}} </pre> </div> <script> var app = angular.module("app", []); app.controller('controllerName', ['$scope', function ($scope) { $scope.cars = ['AUDI', 'BMW', 'MERCEDES']; $scope.my = { favorite: 'AUDI' }; }]); </script> </body> </html>
Output