Guest User

Untitled

a guest
Sep 10th, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { Component, Inject, Input } from '@angular/core';
  2. import { PermissionCheckerService } from '../service/permission-checker.service';
  3.  
  4. @Component({
  5.     selector: '[secure]',
  6.     template: `
  7.                   <ng-content *ngIf="isGranted()"></ng-content>`
  8. })
  9. export class IsGrantedComponent {
  10.     @Input() permission: string;
  11.     @Input() resource: any;
  12.  
  13.     constructor (@Inject(PermissionCheckerService) private $permissionChecker: PermissionCheckerService) {
  14.     }
  15.  
  16.     /**
  17.      * @returns {boolean}
  18.      */
  19.     public isGranted = (): boolean => {
  20.         return this.$permissionChecker.isGranted(this.permission, this.resource);
  21.     };
  22. }
Advertisement
Add Comment
Please, Sign In to add comment