I was inspired: redefining the angular size of the material and styling md-dialog-container
I solved it like this:
Create a new component
Create a new ProgressSpinnerDialogComponent component
Contents of progress-spinner-dialog.component.html:
<mat-spinner></mat-spinner>
Contents of progress-spinner-dialog.component.ts:
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-progress-spinner-dialog',
templateUrl: './progress-spinner-dialog.component.html',
styleUrls: ['./progress-spinner-dialog.component.css']
})
export class ProgressSpinnerDialogComponent implements OnInit {
constructor() { }
ngOnInit() {
}
}
Add style
In styles.css add:
.transparent .mat-dialog-container {
box-shadow: none;
background: rgba(0, 0, 0, 0.0);
}
Use component
Here is an example of using a progress counter:
import { Component, OnInit } from '@angular/core';
import { MatDialog, MatDialogRef } from "@angular/material";
import { Observable } from "rxjs";
import { ProgressSpinnerDialogComponent } from "/path/to/progress-spinner-dialog.component";
@Component({
selector: 'app-use-progress-spinner-component',
templateUrl: './use-progress-spinner-component.html',
styleUrls: ['./use-progress-spinner-component.css']
})
export class UseProgressSpinnerComponent implements OnInit {
constructor(
private dialog: MatDialog
) {
let observable = new Observable(this.myObservable);
this.showProgressSpinnerUntilExecuted(observable);
}
ngOnInit() {
}
myObservable(observer) {
setTimeout(() => {
observer.next("done waiting for 5 sec");
observer.complete();
}, 5000);
}
showProgressSpinnerUntilExecuted(observable: Observable<Object>) {
let dialogRef: MatDialogRef<ProgressSpinnerDialogComponent> = this.dialog.open(ProgressSpinnerDialogComponent, {
panelClass: 'transparent',
disableClose: true
});
let subscription = observable.subscribe(
(response: any) => {
subscription.unsubscribe();
console.log(response);
dialogRef.close();
},
(error) => {
subscription.unsubscribe();
dialogRef.close();
}
);
}
}
Add it to app.module
declarations: [...,ProgressSpinnerDialogComponent,...],
entryComponents: [ProgressSpinnerDialogComponent],