angular.js - angular获取radio选项的值,在线等啊亲,连续加班一个礼拜了……
迷茫
迷茫 2017-05-15 17:07:52
0
2
645

单选的选项是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,怎么实现?

真是在线等啊,急啊,已经加班一个礼拜了……江湖救急啊,感激不尽!

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(2)
巴扎黑
<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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!