Skip to content

Instantly share code, notes, and snippets.

@eaponiente
Created August 23, 2017 02:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eaponiente/cc108bfafb2789229e917283e0b8db09 to your computer and use it in GitHub Desktop.
Save eaponiente/cc108bfafb2789229e917283e0b8db09 to your computer and use it in GitHub Desktop.
Angular 4 multiple checkbox not working
this.isClicked = false;
let rolePermissions = [];
this.sub = this.route.params.subscribe((params) => {
this.roleId = +params['id'];
this.roleService
.find(this.roleId)
.subscribe((role) => {
this.role = role.data.attributes;
let rolePermissionsData = role.data.relationships.permissions;
for (let i in rolePermissionsData) {
rolePermissions.push(rolePermissionsData[i].id);
}
console.log(rolePermissions);
});
});
this.roleService.allPermissions()
.subscribe((result) => {
let perm = result.data;
let permissions = [];
for (let i in perm) {
let id = parseInt(perm[i].id);
permissions.push({
value: perm[i].id,
name: perm[i].name,
checked: rolePermissions.indexOf(id) >= 0
});
}
this.permissions = permissions;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment