简体   繁体   English

用于使用AngularJS进行单选检查的自定义过滤器

[英]custom filter for radio check using AngularJS

I want to check the radio button only if the defaultValue became true. 我只想在defaultValue变为true时检查radio按钮。 Without going to function, is any other angular magic to check the radio button on UI. 无需执行任何其他操作即可检查UI上的单选按钮。 Here my json sturcture and html code. 这是我的jsonhtml代码。

 $scope.option = { "optionValues": [
        {
          "id": 2159,
          "name": "Soup",
          "price": 0,
          "defaultValue": true
        },
        {
          "id": 2160,
          "name": "Salad (dressing?)",
          "price": 0,
          "defaultValue": false
        }
      ]}

<table class="table">
   <tr ng-repeat="values in option.optionValues">
      <td><input type="radio" name="value" ng-model="values.name" ng-value="values.name">{{values.name}}</td>
      <td>{{values.price | currency}}</td>
   </tr>
</table>

如果要选中单选输入顶部,则模板中应包含以下ng-model:

 <input type="radio" name="value.name" ng-value="true" ng-model="values.defaultValue">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM