Hi rani,
Check this example. Now please take its reference and correct your code.
HTML
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>AngularJS Radio Buttons Validation</title>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.8/angular.min.js"></script>
<script type="text/javascript">
var app = angular.module('MyApp', []);
app.controller('MyController', function ($scope, $window) {
$scope.Submit = function () {
if ($scope.SelectedFruit != undefined) {
$window.alert('Selected Fruit : ' + $scope.SelectedFruit);
} else {
$window.alert('Please select at-least one Fruit.');
}
}
});
app.controller('MyController1', function ($scope, $window) {
$scope.Fruits = [
{ FruitId: 1, Name: 'Mango' },
{ FruitId: 2, Name: 'Apple' },
{ FruitId: 3, Name: 'Banana' },
{ FruitId: 4, Name: 'Grapes' },
{ FruitId: 5, Name: 'Orange' }
];
$scope.Submit = function () {
if ($scope.SelectedFruitId != undefined) {
var fruitName;
for (var i = 0; i < $scope.Fruits.length; i++) {
if ($scope.Fruits[i].FruitId == $scope.SelectedFruitId) {
fruitName = $scope.Fruits[i].Name;
break;
}
}
$window.alert("Selected Fruit : " + fruitName);
} else {
$window.alert('Please select at-least one Fruit.');
}
}
});
</script>
</head>
<body ng-app="MyApp">
<div ng-controller="MyController">
<input type="radio" value="Mango" ng-model="SelectedFruit" />Mango<br />
<input type="radio" value="Apple" ng-model="SelectedFruit" />Apple<br />
<input type="radio" value="Banana" ng-model="SelectedFruit" />Banana<br />
<input type="radio" value="Grapes" ng-model="SelectedFruit" />Grapes<br />
<input type="radio" value="Orange" ng-model="SelectedFruit" />Orange<br />
<input type="button" id="btnSubmit" value="Submit" ng-click="Submit()" />
</div>
<hr />
<div ng-controller="MyController1">
<div ng-repeat="fruit in Fruits">
<label>
<input type="radio" value="{{fruit.FruitId}}" ng-model="$parent.SelectedFruitId" />
{{fruit.Name}}
</label>
</div>
<input type="button" id="btnSubmit" value="Submit" ng-click="Submit()" />
</div>
</body>
</html>
Demo