Angular Radio Values in ng-repeat
angularjs, javascript
Solution
Do
ng-click="getPlanTypes(item.code)"
and in your controller, you can get the value
$scope.getPlanTypes = function (ed) {
console.log(ed);
}
Problem
I'm new to Angular and am trying to capture the selected radio value but the documentation is not clear when using ng-repeat. Any help would be greatly appreciated. ``` <div ng-repeat="item in ed"> <label for="{{item['code']}}"> <input ng-change="getPlanTypes()" ng-model="ed" type="radio" id="{{item['code']}}" name="effective_date" value="{{item['code']}}"> {{item['date']}} </label> </div> ``` Here is the controller but I'm unsure of the right way to get the selected radio value? ``` rates.controller('getEffectiveDates', function($scope, $http, $location, myService, localStorageService) { myService.effective_dates().then(function(ed) { $scope.ed = ed; }); $scope.getPlanTypes = function() { console.log($scope.ed['code']); //Futile attempt that returns undefined localStorageService.add('code',$scope.ed['code']); $location.path("/plan-types"); } }); ```