Skip to content

Instantly share code, notes, and snippets.

@LironHazan
Last active October 4, 2018 11:16
Show Gist options
  • Save LironHazan/41256b20da974e0c64fe3fa594249e98 to your computer and use it in GitHub Desktop.
Save LironHazan/41256b20da974e0c64fe3fa594249e98 to your computer and use it in GitHub Desktop.
test paste
import {Injectable, TemplateRef} from '@angular/core';
import {MatDialog} from '@angular/material';
import {ComponentType} from '@angular/cdk/typings/portal';
import {MyDialogComponent} from './my-dialog.component';
@Injectable({
providedIn: 'root'
})
export class MyDialogService {
constructor(public dialog: MatDialog) { }
private conf = { autoFocus: true };
private mediumConf = {height: 'auto', width: '70%', ...this.conf};
public open<T>(component: ComponentType<T> | TemplateRef<T>, data: any) {
this.mediumConf['data'] = { component, data };
const conf = this.mediumConf;
return this.dialog.open(MyDialogComponent, conf);
}
public error<T>(data: any) {
return this.dialog.open(AlertDialogComponent, {panelClass: 'alert-panel', data: data});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment