简体   繁体   中英

ngrepeat checkbox in table rows

Good day everyone. I was hoping someone can help me with my Angular JS code. 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). Thank You.

Use ng-disabled on the checkbox which can have the expression
"vm.selectedGroup !== 'Group 1'" or
"vm.selectedGroup !== group.name" assuming you have a ng-repeat which the element is called group

You can also have some logic to uncheck the checkboxes when the selectedGroup changes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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