lundi 24 octobre 2016

Angularjs selectall using checkbox

I am new to Angularjs. I have some legacy code with me. I want to select all checkboxes once parent checkbox is selected. Below is my parent checkbox.

<div class="form-group">
    <label for="test" class="col-xs-3 control-label"></label>
    <input type="checkbox" class="col-xs-1" checked>
</div>

if someone checks this one all the remaining checkboxes should be checked.Below is my child checkbox

<div class="form-group">
    <label for="firstName" class="col-xs-3 control-label">First Name</label>
    <input id="" type="checkbox" value="" ng-checked="selection.indexOf(fields[0].name) > -1" ng-click="toggleSelection(fields[0].name)" class="col-xs-1" />
    <div ng-class="{'col-xs-4':test && !tableView, 'col-xs-8':!isAvailable || test && tableView, 'review-column': true, even: true}">
    <input type="text" class="form-control" id="name2" ng-model="data.name.firstName" focus="" value=""></input>
</div>

I tried many suggestions but nothing seems to work. Can some one point one the correct html to do so along with controller js code..Many thanks




Aucun commentaire:

Enregistrer un commentaire