我是Angular的新手,我試圖捕獲選定的無線電值,但使用ng-repeat時文檔不清晰。任何幫助將不勝感激。ng-repeat中的角度無線電值
<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>
這裏是控制器,但我不確定正確的方式來獲取選定的無線電值?
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");
}
});
看起來應該根據所選擇的無線電的值,來更新NG-模型,如果你這樣做,而不是:執行console.log($ scope.ed); – shaunhusain