title: Directive that works as ng-if (Angular 2)
body: <p>I'm trying to create a directive that works as a ngIf to control if the user with the correct permission is allow to see specific content, something like this:</p>
  
  <pre><code>&lt;div [type-of-user]="load data from the user and check it (normal or premium)"&gt;
      &lt;h3&gt;You are allow to see this.&lt;/h3&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I was reading about how to do it and found on this <a href="https://angular.io/docs/ts/latest/guide/attribute-directives.html" rel="noreferrer">doc</a> about "Attribute Directives" but I still can't implement it (I am new with Angular 2)</p>
  
  <p>So far I have this:</p>
  
  <pre><code>import {Directive, ElementRef, Input} from '@angular/core';
  
  @Directive({
    selector: '[type-of-user]'
  })
  
  export class TypeOfUserDirective{
  
    constructor(private el: ElementRef){}
  
    @Input('type-of-user') userControl: string;
  
    private haspermission(permission: string) {
      /*the style background color is just to test if works*/
      this.el.nativeElement.style.backgroundColor = permission;
    }
  
  }
  </code></pre>
  
  <p>I already added the directive in the app.module.</p>
  
  <p>Any advice how to proceed would be great.</p>