获取单选按钮选定值

Getting radio button selected value

本文关键字:单选按钮 获取      更新时间:2023-09-26

如何获得单选按钮点击值?

实际上,我需要一个自定义过滤器的性别,我选择在我的<form>。从输出中,我需要过滤性别。我的filterorderByng-repeat不能正常工作。

下面是我的Plunker示例的链接:http://plnkr.co/edit/7ZBcMDrJzSreD73R9aNq?p=preview

for(var i=0;i<$scope.details.length;i++) {
    if($scope.details[i]===$scope.options[i])
        $scope.details=myService.getForm($scope.user);
}

在你的Plunker给定的值从性别是在$scope.user

 $scope.submitTheForm=function(){
    myService.setForm($scope.user);
    $scope.user={};
}; 

查看工作演示

我不确定你的jsfiddle,但这里有一个快速的例子,你如何做到:

<div class="radio" data-ng-repeat="detail in details">
    <label>
        <input type="radio" data-ng-model="$parent.ngModel" name="ngModel" value="{{detail.id}}" required />
        {{detail.title}}
    </label>
</div>

在你的控制器只使用$scope.ngModel,你会得到结果。