将ng-repeat中的单选按钮设置为选中

何塞软管

晚上都。有人可以告诉我如何在加载ng-repeat时设置单选按钮吗?在下表中,我列出了具有创建的排序功能的价格。它从最低价格到最低排序。有什么方法可以将每次加载表格时的最低价格单选按钮设置为“选中”?

<table> 
<tr ng-repeat="prices in productVariant.prices | orderBy: tcoSort">
    <td><strong>{{prices.code }}</strong></td>
    <td ng-click="displayFullPricing(prices)">
            <input type="radio"  name="{{variant.code}}" ng-click="displayFullPricing(prices, $index)">
        </td>
</tr>

$scope.tcoSort = function (productVariant) {
return  productVariant.nonRecurring.retailPrice + (productVariant.monthly.retailPrice * $scope.productAttributesObj.Term);
};

谢谢

松鼠

非常简单地使用$ scope.modelName并将其值设置为您要默认设置的单选按钮的任何值(属性),例如:

男女

现在在控制器中设置$ scope.one =“ male”,您将获得默认值单选按钮。

如果ng-repeat概念相同,但是您只需要在ng-repeat模型中使用$ parent,因为ng-repeat创建了自己的作用域,无法从控制器访问它。

下面是一个小的模拟示例:

 <div ng-repeat="check in people">
                <input type="radio" name="hello" value="{{check.name}}" ng-model="$parent.human"/> {{check.name}}
                </div>

 $scope.people=[
        { 
            'name':'rachit'
        },
        { 
            'name':'gulati'
        },
        { 
            'name':'rocks'
        }
    ]
    $scope.human='gulati';//You need to set it to the lowest price from your array .

这是小提琴

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

无法使用Angular.js中的ng-repeat设置默认选中的单选按钮的选项

来自分类Dev

无法使用Angular.js中的ng-repeat设置默认选中的单选按钮的选项

来自分类Dev

未选中嵌套ng-repeat中的Angularjs单选按钮

来自分类Dev

将值(int)设置为选中单选按钮WPF

来自分类Dev

将AJAX响应设置为选中的单选按钮

来自分类Dev

是否将类别设置为选中的单选按钮?

来自分类Dev

如何将某个单选按钮设置为选中“ true”

来自分类Dev

将单选按钮设置为会话以保持选中状态

来自分类Dev

将 ng-repeat 中的复选框设置为默认选中

来自分类Dev

在CSS中,如何将复选框或单选按钮设置为按下状态(已选中和未选中)以外的样式?

来自分类Dev

使用ng-repeat时默认选中单选按钮

来自分类Dev

如何将滚动位置设置为选中的单选按钮级别?

来自分类Dev

如果未选中单选按钮,如何将隐藏字段设置为零

来自分类Dev

如何通过更新其FormControl将单选按钮设置为选中状态

来自分类Dev

嵌套ng-repeat中的单选按钮

来自分类Dev

使用ng-repeat在动态单选按钮上设置值

来自分类Dev

默认情况下不选中AngularJS ng-repeat单选按钮

来自分类Dev

ng-repeat中的UI Bootstrap单选按钮

来自分类Dev

ng-repeat中的角度单选按钮模型

来自分类Dev

ng-repeat中的UI Bootstrap单选按钮

来自分类Dev

在ng-repeat中无法单击单选按钮

来自分类Dev

如何将通过tkinter中的循环创建的单选按钮值设置为默认值?

来自分类Dev

在MVC中手动将单选按钮/复选框设置为true

来自分类常见问题

Android:如何将单选按钮的文本设置为Integer?

来自分类Dev

将ng-model值设置为按钮单击

来自分类Dev

* ng是否可以将按钮文本设置为角度2?

来自分类Dev

如何根据选中的单选按钮将微调框值重置为“由某物选择”

来自分类Dev

AngularJS:单选按钮上的ng-repeat

来自分类Dev

选中的单选按钮在ng-model中返回未定义

Related 相关文章

  1. 1

    无法使用Angular.js中的ng-repeat设置默认选中的单选按钮的选项

  2. 2

    无法使用Angular.js中的ng-repeat设置默认选中的单选按钮的选项

  3. 3

    未选中嵌套ng-repeat中的Angularjs单选按钮

  4. 4

    将值(int)设置为选中单选按钮WPF

  5. 5

    将AJAX响应设置为选中的单选按钮

  6. 6

    是否将类别设置为选中的单选按钮?

  7. 7

    如何将某个单选按钮设置为选中“ true”

  8. 8

    将单选按钮设置为会话以保持选中状态

  9. 9

    将 ng-repeat 中的复选框设置为默认选中

  10. 10

    在CSS中,如何将复选框或单选按钮设置为按下状态(已选中和未选中)以外的样式?

  11. 11

    使用ng-repeat时默认选中单选按钮

  12. 12

    如何将滚动位置设置为选中的单选按钮级别?

  13. 13

    如果未选中单选按钮,如何将隐藏字段设置为零

  14. 14

    如何通过更新其FormControl将单选按钮设置为选中状态

  15. 15

    嵌套ng-repeat中的单选按钮

  16. 16

    使用ng-repeat在动态单选按钮上设置值

  17. 17

    默认情况下不选中AngularJS ng-repeat单选按钮

  18. 18

    ng-repeat中的UI Bootstrap单选按钮

  19. 19

    ng-repeat中的角度单选按钮模型

  20. 20

    ng-repeat中的UI Bootstrap单选按钮

  21. 21

    在ng-repeat中无法单击单选按钮

  22. 22

    如何将通过tkinter中的循环创建的单选按钮值设置为默认值?

  23. 23

    在MVC中手动将单选按钮/复选框设置为true

  24. 24

    Android:如何将单选按钮的文本设置为Integer?

  25. 25

    将ng-model值设置为按钮单击

  26. 26

    * ng是否可以将按钮文本设置为角度2?

  27. 27

    如何根据选中的单选按钮将微调框值重置为“由某物选择”

  28. 28

    AngularJS:单选按钮上的ng-repeat

  29. 29

    选中的单选按钮在ng-model中返回未定义

热门标签

归档