AngularJs - Disable input on table dependent upon top row selection -


i trying make tables input elements disabled below top (master) row if "active" or "engaged" boolean set true on top row. not want them loose data below top row when set true, disable it. if user sets "active" && "engaged" false on top row want them able edit data below top row again. there easy way angularjs?

here example: https://jsfiddle.net/7kg6kuzm/2/

<body ng-app="test" ng-controller="appctrl"> <p>{{test}}</p> <table class="table table-bordered">     <thead>         <tr>             <th class="border-less"></th>             <th>people</th>             <th>active</th>             <th>engaged</th>             <th>town</th>         </tr>     </thead>     <tbody>         <tr ng-repeat="(month, info) in months">             <td><p>{{month}}</p></td>             <td><input type="text" ng-model="info.people"/></td>             <td><input type="checkbox" ng-model="info.active"/></td>             <td><input type="checkbox" ng-model="info.engaged"/></td>             <td><input type="text" ng-model="info.form" /></td>         </tr>     </tbody> 

possible json object value (in case since "all" or top row has 1 of booleans set true rest of rows disabled):

var months = {   "all": {"people":25,"active":true,"engaged":false,"form":"test0"},   "jan": {"people":63,"active":false,"engaged":true,"form":"test2"},   "feb": {"people":46,"active":true,"engaged":false,"form":"test3"},   "mar": {"people":65,"active":false,"engaged":false,"form":"test4"},   "apr": {"people":66,"active":true,"engaged":true,"form":"test5"},   "may": {"people":67,"active":false,"engaged":true,"form":"test6"} } 

i figured out, putting future reference or if else needs know how this:

https://jsfiddle.net/7kg6kuzm/3/

i ended putting check on each input line , checking value of first line:

<td><input ng-disabled="(months['all'].active || months['all'].engaged) && this.month!=='all'" type="text" ng-model="info.people"/></td> 

Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -