NetanelBasal
10/21/2017 - 6:47 PM

dynamic-views-7.ts

@Directive({
  selector: '[sidebar]'
})
export class SidebarDirective {
  private _viewRef : ViewRef;

  constructor( private _sidebarService: SidebarService, 
               public tpl: TemplateRef<any> ) {
  }

  ngOnInit() {
    this._viewRef = this._sidebarService.vcr.createEmbeddedView(this.tpl);
  }

  ngOnDestroy() {
    this._viewRef.destroy();
  }

}