Last active
March 14, 2022 17:12
-
-
Save Stradivario/33a30ac8daf54c49da57483024fe1ac1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Component} from '@angular/core'; | |
@Component({ | |
selector: 'open-overlay', | |
template: ` | |
<div (click)="onOpen($event)" cdkOverlayOrigin #trigger="cdkOverlayOrigin"> | |
<ng-content select="[header]"> </ng-content> | |
</div> | |
<ng-template | |
cdkConnectedOverlay | |
[cdkConnectedOverlayOrigin]="trigger" | |
[cdkConnectedOverlayOpen]="isOpen" | |
(overlayOutsideClick)="onOutsideClick()" | |
> | |
<div | |
class="mat-elevation-z1" | |
style="background: white; padding-right: 0px; padding: 20px 15px" | |
> | |
<ng-content select="[body]"></ng-content> | |
</div> | |
</ng-template> | |
`, | |
}) | |
export class SelectOverlayComponent { | |
isOpen = false; | |
onOpen(event: Event) { | |
event.preventDefault(); | |
this.isOpen = !this.isOpen; | |
} | |
onOutsideClick() { | |
this.isOpen = false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment