File

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

Description

Service to show toaster

Index

Properties
Methods

Constructor

constructor()

Constructor to create injected service(s) object

Methods

custom
custom(config: any)

Custom toaster message to be configured

Parameters :
Name Type Optional
config any No
Returns : void
error
error(message: string)

Format error message

Parameters :
Name Type Optional Description
message string No
  • Error message
Returns : void
info
info(message: string)

Format information message

Parameters :
Name Type Optional Description
message string No
  • Info message
Returns : void
success
success(message: string)

Format success message

Parameters :
Name Type Optional Description
message string No
  • Success message
Returns : void
warning
warning(message: string)

Format warning message

Parameters :
Name Type Optional Description
message string No
  • Warning message
Returns : void

Properties

Public iziToast
Type : any

To show toaster messages

import { Injectable } from '@angular/core';

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

  /**
   * To show toaster messages
   */
  public iziToast: any;

  /**
	 * Constructor to create injected service(s) object
	 */
  constructor() {
    this.iziToast = iziToast; // global object
    this.iziToast.settings({
      position: 'topCenter',
      titleSize: '18'
    });
  }

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

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

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

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

  /**
   * Custom toaster message to be configured
   * @param config
   */
  custom(config: any) {
    this.iziToast.show({
      class: config.class,
      message: config.message
    });
  }
}

results matching ""

    No results matching ""