简体   繁体   中英

AngularJS bind objects with checkbox

I have a nested list of object up to three level state. For each object there is a nested object itself up to n-level. I want to bind that object directly with the checkbox such that if I check any item It should get a direct impact on that particular object. IS there any way in angular to do that? A sample object is below.

Object which I am getting from the server side:

[{
    "name": "nvs_core",
    "discovered": [{
        "name": "tag",
        "Fields": [{
            "name": "tag",
       }]
    }]
    }]
}, {
    "name": "nvs_core_trial",
    "discovered": [{
        "name": "nvs_src_tag",
        "Fields": [{
            "name": "nid",
        }]
    }, 
    }]
}]

您可以将模型附加到复选框,如果您想要不同的值用于选中/未选中,则可以在此处查看示例https://docs.angularjs.org/api/ng/input/input%5Bcheckbox%5D底部页面

<input type="checkbox" ng-model="myobj.discovered.Fields.name.checked" ng-repeat="myobj in ArrayOfObjects"/> 

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