ngx-permission-control
v0.0.2
Published
Permission control directive.
Downloads
1
Readme
Angular Permission Control
Permission control directive.
Getting started
Installation:
Install via npm package manager
ngx-permission-control
App.module.ts
import { PermissionDirective } from 'ngx-permission-control';
declarations: [...
PermissionDirective,
...
]
Input fields type:
@Input('libPermission') arrPermission: Array<any>;
@Input('hasPermission') hasPermission: boolean; //OPTIONAL - default true
libPermission - array or array object
<div [libPermission]="testArray" [hasPermission]="true"></div>
<div [libPermission]="testArray"</div> //haspirmission is "true"
<div [libPermission]="testArray" [hasPermission]="false"></div>
<div [libPermission]="testArrayObject"></div>
"[hasPermission]" is work with only simple array(testArray). If haspirmission is true testArray contain the user role. If haspirmission is true testArray not contain the user role.
.ts
constructor(
private persmissionServecie: NgxPermissionControlService ) {}
changetype() {
this.persmissionServecie.changeUserPerm('admin');
this.perm = this.persmissionServecie.getPerm();
this.persmissionServecie.changeUserStatus(1);
this.userStatus = this.persmissionServecie.getStatus();
}
Example-[libpermission]
testArray = ['admin', 'admin2', 'test2'];
testAraryObject = [
{
key: 'admin',
value: [1, 2, 4]
},
{
key: 'office',
value: [0, 1, 2, 3, 4]
}
]