javascript - Angular table and HTML Checked Boxes with Disabling Feature in Remaining Checked Boxes -
the goal have checked boxes become disabled when 1 box checked. when use jquery code below, reason not work in solution mentioned here.
in example populating table using mvc controller in nodejs , angular stack. when table displays, there checkbox next each name prints in table. is there solution correctly disable checkboxes being populated in angular script when 1 checked box selected?
html
<table> <thead> <th>names</th> </thead> <tr dir-paginate="x in names | filter:search | itemsperpage:8"> <div class="checkbox" id="namelist"> <td><label><input type="checkbox" name="name" value={{x.name}}> {{ x.name }}</label></td> </div> </tr> </table>
js
$(document).ready(function(){ $('#namelist input[type=checkbox]').change(function(){ if($(this).is(':checked')){ $('#namelist').find(':checkbox').not($(this)).attr('disabled',true); }else{ $('#namelist').find(':checkbox').attr('disabled',false); } }); })
try using ng-change , ng-model directives of angular handle these things.
refer here https://docs.angularjs.org/api/ng/input/input%5bcheckbox%5d.
Comments
Post a Comment