import { Directive, Input, TemplateRef, ViewContainerRef } from '@angular/core';

@Directive({
  selector: '[myNgIf]'
})
export class MyNgIf
{
  public constructor(
    private templateRef: TemplateRef<any>,
    private viewContainer: ViewContainerRef)
  {
  }

  @Input() set myNgIf(condition: boolean)
  {
    if (condition) {
      this.viewContainer.createEmbeddedView(this.templateRef);
    } else {
      this.viewContainer.clear();
      
    }
  }
}