File

src/app/modules/shared/services/toaster/toaster.service.ts

Description

Service to show toaster

Constructor

constructor()

Constructor to create injected service(s) object

Methods

InfoToasterCritical
InfoToasterCritical(title: string, message: string)
Returns: void
success
success(title: string, message: string)

Format success message

Parameters :
  • message
    • Success message
Returns: void
info
info(title: string, message: string)

Format information message

Parameters :
  • message
    • Info message
Returns: void
error
error(title: string, message: string)

Format error message

Parameters :
  • message
    • Error message
Returns: void
warning
warning(title: string, message: string)

Format warning message

Parameters :
  • message
    • Warning message
Returns: void

Properties

Private iziToast
iziToast: any

To show toaster messages

Private options
options: { position: string; titleSize: string; timeout: number; transitionIn: string; transitionOut: stri...
import { Injectable } from '@angular/core';

/**
 * Service to show toaster
 *
 */
@Injectable()
export class ToasterService {

  /**
   * To show toaster messages
   */
  private iziToast: any;
  private options = {
    position: 'topCenter',
    titleSize: '18',
    timeout: 6000,
    transitionIn: 'flipInX',
    transitionOut: 'flipOutX'
  };
  /**
	 * Constructor to create injected service(s) object
	 */
  constructor() {
    this.iziToast = iziToast; // global object
  }

  InfoToasterCritical(title: string, message: string) {
    iziToast.show({
      title: title,
      message: message,
      class: 'sb-toaster sb-toast-success sb-toast-normal',
      position: 'topCenter',
      timeout: 6000,
      transitionIn: 'flipInX',
      transitionOut: 'flipOutX'
    });
  }

  /**
   * Format success message
   * @memberOf Services.toasterService
   * @param {string}  message - Success message
   */
  success(title: string, message?: string) {
    this.iziToast.success({
        title: title,
        message: message ? message : '',
        class: 'sb-toaster sb-toast-normal sb-toast-success',
         ...this.options
        });
  }

  /**
   * Format information message
   * @memberOf Services.toasterService
   * @param {string}  message - Info message
   */
  info(title: string, message?: string) {
    this.iziToast.info({
      title: title,
      message: message ? message : '',
      class: 'sb-toaster sb-toast-normal sb-toast-info',
       ...this.options
    });
  }



  /**
   * Format error message
   * @memberOf Services.toasterService
   * @param {string}  message - Error message
   */
  error(title: string, message?: string) {
    this.iziToast.error({
      title: title,
      message: message ? message : '',
      class: 'sb-toaster sb-toast-normal sb-toast-danger',
       ...this.options
    });
  }

  /**
   * Format warning message
   * @memberOf Services.toasterService
   * @param {string}  message - Warning message
   */
  warning(title: string, message?: string) {
    this.iziToast.warning({
      title: title,
      message: message ? message : '',
      class: 'sb-toaster sb-toast-normal sb-toast-warning',
       ...this.options
    });
  }
}

results matching ""

    No results matching ""