简体   繁体   English

表格行中的 ngrepeat 复选框

[英]ngrepeat checkbox in table rows

Good day everyone.今天是个好日子。 I was hoping someone can help me with my Angular JS code.我希望有人可以帮助我处理我的 Angular JS 代码。 I have an image我有一张图片

在此处输入图片说明

which was populated based on this array of objects.这是基于这个对象数组填充的。

[
  {
    "groupName": "Group 1",
    "devices": [
      {
        "deviceId": "1111",
        "modelName": "Model 1",
        "baseModelName": "base1",
        "serialNumber": "ZZZZZZZZZZZ",
        "ipAddress": "10.191.21.50",
        "description": "Device 1"
      },
      {
        "deviceId": "2222",
        "modelName": "Model 2",
        "baseModelName": "base2",
        "serialNumber": "YYYYYYYY",
        "ipAddress": "10.191.21.168",
        "description": "Device 1"
      }
    ]
  },
  {
    "groupName": "Group 2",
    "devices": [
      {
        "deviceId": "333",
        "modelName": "Model 3",
        "baseModelName": "base3",
        "serialNumber": "XXXXXXXXXX",
        "ipAddress": "10.191.21.124",
        "description": "Device 1"
      }
    ]
  }
]

Would appreciate if anyone can help me in coding my angularjs javascript controller so that I can only check/uncheck the checkbox under the selected group(the radio button).如果有人可以帮助我编写我的 angularjs javascript 控制器,以便我只能选中/取消选中所选组(单选按钮)下的复选框,我将不胜感激。 Thank You.谢谢你。

Use ng-disabled on the checkbox which can have the expression在可以具有表达式的复选框上使用ng-disabled
"vm.selectedGroup !== 'Group 1'" or "vm.selectedGroup !== 'Group 1'"
"vm.selectedGroup !== group.name" assuming you have a ng-repeat which the element is called group "vm.selectedGroup !== group.name"假设你有一个ng-repeat ,该元素被称为group

You can also have some logic to uncheck the checkboxes when the selectedGroup changes.您还可以使用一些逻辑在selectedGroup更改时取消选中复选框。

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

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