Skip to content

Instantly share code, notes, and snippets.

@AvocadoVenom
Last active October 3, 2019 22:14
Show Gist options
  • Select an option

  • Save AvocadoVenom/bac42a699e67654e4a2a9e2833ed41b7 to your computer and use it in GitHub Desktop.

Select an option

Save AvocadoVenom/bac42a699e67654e4a2a9e2833ed41b7 to your computer and use it in GitHub Desktop.
Overlay Loading DIrective > App Component
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