单选的选项是ng-repeat出来的,
<label class="radio-inline" ng-repeat="list in fruits">
<input type="radio" name="sample" value="{{list.fruitName}}"> {{list.fruitName}}
</label>
// list对象格式
list = {
fruitName: '苹果',
id: 001
};
现在想要获取被选中的那个选项的id
,比如,我选择了苹果,这个时候返回苹果的id 001
,怎么实现?
真是在线等啊,急啊,已经加班一个礼拜了……江湖救急啊,感激不尽!
巴扎黑2017-05-15 17:09:52
<label class="radio-inline" ng-repeat="list in fruits">
<input type="radio" name="sample" ng-value="list.id" ng-model="id"> {{list.fruitName}}
</label>
You can get it by using $scope.id in the controller