As I consider this table row, my goal is to dynamically control the activation of checkboxes:
function manageRoles(data){
var allRoles = [
{role1: true, name: "Role One", active: true},
{role2: false, name: "Role Two", active: false},
{role3: true, name: "Role Three", active: true},
{role4: false, name: "Role Four", active: false},
{role5: true, name: "Role Five", active: true},
{role6: false, name: "Role Six", active: false},
{role7: true, name: "Role Seven", active: true},
{role8: false, name: "Role Eight", active: false},
{role9: true, name: "Role Nine", active: true},
{role10: false, name: "Role Ten", active: false}
];
}
<tr>
<td>
<input type="checkbox" name="role1" ng-model="ctrl.data.roles.role1" /> Role One
</td>
<td>
<input type="checkbox" name="role2" ng-model="ctrl.data.roles.role2" /> Role Two
</td>
<td>
<input type="checkbox" name="role3" ng-model="ctrl.data.roles.role3" /> Role Three
</td>
<td>
<input type="checkbox" name="role4" ng-model="ctrl.data.roles.role4" /> Role Four<
</td>
</tr>
<tr>
<td>
<input type="checkbox" name="role5" ng-model="ctrl.data.roles.role5" /> Role Five
</td>
<td>Role Six</td>
<td>Role Seven</td>
<td>Role Eight</td>
</tr>
I have successfully processed the data from an Angular service and created a new array called allRoles
.
Next, I aim to connect the allRoles
array with the checkbox
inputs within my view to enable or disable as needed.
In essence, if the checkbox for "Role One" should be enabled, then ng-model=ctrl.data.roles.role1
should reflect the active
property from the allRoles
array.
Maybe looping through ng-model
?
Any insights are welcome. Meanwhile, I will continue to investigate ...