Skip to content

Instantly share code, notes, and snippets.

@venkateshwarv
Last active August 5, 2018 16:30
Show Gist options
  • Save venkateshwarv/e78c5f215b87ea8659b37b3a4816730f to your computer and use it in GitHub Desktop.
Save venkateshwarv/e78c5f215b87ea8659b37b3a4816730f to your computer and use it in GitHub Desktop.
Typescript for step one
import { Portal, TemplatePortal } from '@angular/cdk/portal';
// [redacted]
showPopUp() {
if ( !this._overlayOpened) {
this._startAnimation();
this.input.setValue( '', { emitEvent: true } );
this._overlayOpened = true;
this._createOverlay().attach( this._portal );
}
}
private _createOverlay(): OverlayRef {
if ( !this._overlayRef ) {
this._portal = new TemplatePortal(
<any>this.optionsPanel,
this._viewContainerRef
);
const config = this._getOverlayConfig();
this._overlayRef = this._overlay.create( config );
this._overlayRef.backdropClick().subscribe( () => {
this.closeMenu();
} );
}
return this._overlayRef;
}
closeMenu() {
this._resetAnimation();
if ( this._overlayRef && !this.inlineOptions ) {
this._overlayOpened = false;
this._overlayRef.detach();
this._overlay = null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment