Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Component, Inject, Input } from '@angular/core';
- import { PermissionCheckerService } from '../service/permission-checker.service';
- @Component({
- selector: '[secure]',
- template: `
- <ng-content *ngIf="isGranted()"></ng-content>`
- })
- export class IsGrantedComponent {
- @Input() permission: string;
- @Input() resource: any;
- constructor (@Inject(PermissionCheckerService) private $permissionChecker: PermissionCheckerService) {
- }
- /**
- * @returns {boolean}
- */
- public isGranted = (): boolean => {
- return this.$permissionChecker.isGranted(this.permission, this.resource);
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment