@angular/cdk/portal#CdkPortalOutlet TypeScript Examples

The following examples show how to use @angular/cdk/portal#CdkPortalOutlet. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: tab-body.component.ts    From alauda-ui with MIT License 6 votes vote down vote up
/**
 * The portal host directive for the contents of the tab.
 */
@Directive({
  selector: '[auiTabBodyHost]',
})
export class TabBodyPortalDirective
  extends CdkPortalOutlet
  implements OnInit, OnDestroy
{
  private _hostSubscription = Subscription.EMPTY;

  constructor(
    componentFactoryResolver: ComponentFactoryResolver,
    viewContainerRef: ViewContainerRef,
    private readonly _host: TabBodyComponent,
  ) {
    super(componentFactoryResolver, viewContainerRef);
  }

  /** Set initial visibility or set up subscription for changing visibility. */
  override ngOnInit(): void {
    super.ngOnInit();
    this._hostSubscription = this._host.content$.subscribe(content => {
      if (this.hasAttached) {
        this.detach();
      }
      this.attach(content);
    });
  }

  override ngOnDestroy() {
    this._hostSubscription.unsubscribe();
  }
}
Example #2
Source File: dialog.component.ts    From alauda-ui with MIT License 5 votes vote down vote up
@ViewChild(CdkPortalOutlet, { static: true })
  portalOutlet: CdkPortalOutlet;
Example #3
Source File: drawer.component.ts    From alauda-ui with MIT License 5 votes vote down vote up
@ViewChild(CdkPortalOutlet, { static: false })
  bodyPortalOutlet: CdkPortalOutlet;
Example #4
Source File: notification.component.ts    From alauda-ui with MIT License 5 votes vote down vote up
@ViewChild(CdkPortalOutlet, { static: true })
  private readonly portalOutlet: CdkPortalOutlet;
Example #5
Source File: tab-body.component.ts    From alauda-ui with MIT License 5 votes vote down vote up
/** The portal host inside of this container into which the tab body content will be loaded. */
  @ViewChild(CdkPortalOutlet, { static: true })
  _portalOutlet: CdkPortalOutlet;