Last active
October 3, 2019 22:14
-
-
Save AvocadoVenom/bac42a699e67654e4a2a9e2833ed41b7 to your computer and use it in GitHub Desktop.
Overlay Loading DIrective > App Component
This file contains hidden or 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'; | |
| import { Overlay } from '@angular/cdk/overlay'; | |
| import { ComponentPortal } from '@angular/cdk/portal'; | |
| import { LoaderComponent } from './loader/loader.component'; | |
| @Component({ | |
| selector: 'app-root', | |
| template: | |
| `<mat-card> | |
| <mat-card-header> | |
| <mat-card-title>Overlay Loading Components</mat-card-title> | |
| </mat-card-header> | |
| <mat-card-content> | |
| <button mat-raised-button | |
| color="primary" | |
| (click)="showOverlay()">Show Overlay</button> | |
| </mat-card-content> | |
| </mat-card>` | |
| }) | |
| export class AppComponent { | |
| constructor(private overlay: Overlay) { } | |
| showOverlay() { | |
| const overlayRef = this.overlay.create({ | |
| positionStrategy: this.overlay.position().global().centerHorizontally().centerVertically(), | |
| hasBackdrop: true | |
| }); | |
| overlayRef.attach(new ComponentPortal(LoaderComponent)); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment