angular.js - angular gets the value of the radio option, waiting online, dear, I have been working overtime for a week...
迷茫
迷茫 2017-05-15 17:07:52
0
2
785

The radio selection options are generated by 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
};

Now I want to 获取被选中的那个选项的id. For example, if I choose Apple, Apple’s ID 001 will be returned at this time. How to achieve this?

I’m really waiting online. I’m so anxious. I’ve been working overtime for a week...Jianhu is asking for help. Thank you very much!

迷茫
迷茫

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

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