How to use the @angular/material.MatSnackBarConfig function in @angular/material

To help you get started, we’ve selected a few @angular/material examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MycroftAI / selene-ui / projects / sso / src / app / modules / login / login.component.ts View on Github external
openErrorSnackbar(errorMessage: string) {
        const config = new MatSnackBarConfig();
        // config.duration = 1000;
        config.data = {type: 'error', message: errorMessage};
        this.snackbar.openFromComponent(SnackbarComponent, config);
    }
}
github maciejtreder / ng-toolkit / application / src / app / services / snack-bar.service.ts View on Github external
private runCarousel(): void {
    if (this.snackbarOpened) {
      if (!this.actuallyDisplayedNotification.force && this.snackBarNotificationsForceQueue.size() > 0) {
        this.snackBar.dismiss();
      }
      return;
    }
    this.loadNotificationToDisplay();
    if (this.actuallyDisplayedNotification == null) {
      return;
    }

    this.snackbarOpened = true;

    const config: MatSnackBarConfig = new MatSnackBarConfig();
    config.duration = 1000 * this.actuallyDisplayedNotification.duration;
    const callback = this.actuallyDisplayedNotification.callback;

    this.snackBar.open(this.actuallyDisplayedNotification.message, this.actuallyDisplayedNotification.action, config).afterDismissed().subscribe(() => {
      if (callback) {
        callback();
      }
      this.snackbarOpened = false;
      this.runCarousel();
    });
  }
}
github angular / components / src / demo-app / snack-bar / snack-bar-demo.ts View on Github external
private _createConfig() {
    const config = new MatSnackBarConfig();
    config.verticalPosition = this.verticalPosition;
    config.horizontalPosition = this.horizontalPosition;
    config.duration = this.setAutoHide ? this.autoHide : 0;
    config.panelClass = this.addExtraClass ? ['demo-party'] : undefined;
    config.direction = this.dir.value;
    return config;
  }
}
github particl / particl-desktop / src / app / core / snackbar / snackbar.service.ts View on Github external
open(message: string, type?: string, action?: string): void {
    const config = new MatSnackBarConfig();

    config.duration = (
      ['err', 'warn'].includes(type) ? 10000 :
      'info' === type ? 5000 : 2000);

    this.snackBar.open(message, action ? action : 'Dismiss', config);
  }
github CoralTime / CoralTime / frontend / src / app / core / notification.service.ts View on Github external
constructor(private snackBar: MatSnackBar) {
		this.config = new MatSnackBarConfig();
		this.config.duration = 3000;
	}
github MycroftAI / selene-ui / projects / sso / src / app / modules / login / internal-login / internal-login.component.ts View on Github external
resetPassword() {
        const successMessage = 'Password reset instructions sent';
        const errorMessage = 'An error occurred sending the instructions email';
        const snackbarConfig = new MatSnackBarConfig();
        snackbarConfig.duration = fiveSeconds;
        snackbarConfig.panelClass = 'mycroft-no-action-snackbar';
        this.authService.resetPassword(this.passwordResetForm.controls['email']).subscribe(
            () => { this.snackBar.open(successMessage, null, snackbarConfig); },
            () => { this.snackBar.open(errorMessage, null, snackbarConfig); }
        );
    }
}
github MycroftAI / selene-ui / projects / account / src / app / modules / skill / skill-setting / skill-settings.component.ts View on Github external
openErrorSnackbar() {
        const config = new MatSnackBarConfig();
        config.data = {
            type: 'error',
            message: 'Error saving changes to ' + this.skill.name + ' settings'
        };
        this.snackbar.openFromComponent(SnackbarComponent, config);
    }
github stbui / angular-material-app / src / app / materials / toast / toast.component.ts View on Github external
showSimpleToast() {
    let config = new MatSnackBarConfig();
    config.duration = this.durationHide;
    this.snackBar.open(this.message, this.action && this.actionButtonLabel, config);
  }