ngx-toastr

  • Version 14.1.3
  • Published
  • 501 kB
  • 1 dependency
  • MIT license

Install

npm i ngx-toastr
yarn add ngx-toastr
pnpm add ngx-toastr

Overview

Toastr for Angular

Index

Variables

Classes

Interfaces

Type Aliases

Variables

variable DefaultGlobalConfig

const DefaultGlobalConfig: GlobalConfig;

    variable DefaultNoAnimationsGlobalConfig

    const DefaultNoAnimationsGlobalConfig: GlobalConfig;

      variable DefaultNoComponentGlobalConfig

      const DefaultNoComponentGlobalConfig: GlobalConfig;

        variable TOAST_CONFIG

        const TOAST_CONFIG: any;

          Classes

          class BasePortalHost

          abstract class BasePortalHost {}
          • Partial implementation of PortalHost that only deals with attaching a ComponentPortal

          method attach

          attach: (portal: ComponentPortal<any>, newestOnTop: boolean) => any;

            method attachComponentPortal

            abstract attachComponentPortal: <T>(
            portal: ComponentPortal<T>,
            newestOnTop: boolean
            ) => any;

              method detach

              detach: () => void;

                method setDisposeFn

                setDisposeFn: (fn: () => void) => void;

                  class ComponentPortal

                  class ComponentPortal<T> {}
                  • A ComponentPortal is a portal that instantiates some Component upon attachment.

                  constructor

                  constructor(component: ComponentType<T>, injector: any);

                    property component

                    component: ComponentType<T>;
                    • The type of the component that will be instantiated for attachment.

                    property injector

                    injector: any;
                    • Injector used for the instantiation of the component.

                    property isAttached

                    readonly isAttached: boolean;
                    • Whether this portal is attached to a host.

                    property viewContainerRef

                    viewContainerRef: any;
                    • [Optional] Where the attached component should live in Angular's *logical* component tree. This is different from where the component *renders*, which is determined by the PortalHost. The origin necessary when the host is outside of the Angular application context.

                    method attach

                    attach: (host: BasePortalHost, newestOnTop: boolean) => any;
                    • Attach this portal to a host.

                    method detach

                    detach: () => void;
                    • Detach this portal from its host

                    method setAttachedHost

                    setAttachedHost: (host?: BasePortalHost) => void;
                    • Sets the PortalHost reference without performing attach(). This is used directly by the PortalHost when it is performing an attach() or detach().

                    class Overlay

                    class Overlay {}
                    • Service to create Overlays. Overlays are dynamically added pieces of floating UI, meant to be used as a low-level building building block for other components. Dialogs, tooltips, menus, selects, etc. can all be built using overlays. The service should primarily be used by authors of re-usable components rather than developers building end-user applications.

                      An overlay *is* a PortalHost, so any kind of Portal can be loaded into one.

                    constructor

                    constructor(
                    _overlayContainer: OverlayContainer,
                    _componentFactoryResolver: any,
                    _appRef: any,
                    _document: any
                    );

                      method create

                      create: (
                      positionClass?: string,
                      overlayContainer?: ToastContainerDirective
                      ) => OverlayRef;
                      • Creates an overlay.

                        Returns

                        A reference to the created overlay.

                      method getPaneElement

                      getPaneElement: (
                      positionClass?: string,
                      overlayContainer?: ToastContainerDirective
                      ) => HTMLElement;

                        class OverlayContainer

                        class OverlayContainer implements OnDestroy {}
                        • Container inside which all toasts will render.

                        constructor

                        constructor(_document: any);

                          method getContainerElement

                          getContainerElement: () => HTMLElement;
                          • This method returns the overlay container element. It will lazily create the element the first time it is called to facilitate using the container in non-browser environments.

                            Returns

                            the container element

                          method ngOnDestroy

                          ngOnDestroy: () => void;

                            class OverlayRef

                            class OverlayRef {}
                            • Reference to an overlay that has been created with the Overlay service. Used to manipulate or dispose of said overlay.

                            constructor

                            constructor(_portalHost: BasePortalHost);

                              method attach

                              attach: (portal: ComponentPortal<any>, newestOnTop?: boolean) => any;

                                method detach

                                detach: () => void;
                                • Detaches an overlay from a portal.

                                  Returns

                                  Resolves when the overlay has been detached.

                                class Toast

                                class Toast implements OnDestroy {}

                                  constructor

                                  constructor(
                                  toastrService: ToastrService,
                                  toastPackage: ToastPackage,
                                  ngZone?: any
                                  );

                                    property displayStyle

                                    readonly displayStyle: string;
                                    • hides component when waiting to be displayed

                                    property duplicatesCount

                                    duplicatesCount: number;

                                      property message

                                      message?: string;

                                        property ngZone

                                        protected ngZone?: any;

                                          property options

                                          options: IndividualConfig;

                                            property originalTimeout

                                            originalTimeout: number;

                                              property state

                                              state: { value: string; params: { easeTime: string | number; easing: string } };
                                              • controls animation

                                              property title

                                              title?: string;

                                                property toastClasses

                                                toastClasses: string;
                                                • a combination of toast type and options.toastClass

                                                property toastPackage

                                                toastPackage: ToastPackage;

                                                  property toastrService

                                                  protected toastrService: ToastrService;

                                                    property width

                                                    width: number;
                                                    • width of progress bar

                                                    method activateToast

                                                    activateToast: () => void;
                                                    • activates toast and sets timeout

                                                    method delayedHideToast

                                                    delayedHideToast: () => void;

                                                      method ngOnDestroy

                                                      ngOnDestroy: () => void;

                                                        method outsideInterval

                                                        outsideInterval: (func: () => any, timeout: number) => void;

                                                          method outsideTimeout

                                                          outsideTimeout: (func: () => any, timeout: number) => void;

                                                            method remove

                                                            remove: () => void;
                                                            • tells toastrService to remove this toast after animation time

                                                            method resetTimeout

                                                            resetTimeout: () => void;

                                                              method stickAround

                                                              stickAround: () => void;

                                                                method tapToast

                                                                tapToast: () => void;

                                                                  method updateProgress

                                                                  updateProgress: () => void;
                                                                  • updates progress bar width

                                                                  class ToastContainerDirective

                                                                  class ToastContainerDirective {}

                                                                    constructor

                                                                    constructor(el: any);

                                                                      method getContainerElement

                                                                      getContainerElement: () => HTMLElement;

                                                                        class ToastContainerModule

                                                                        class ToastContainerModule {}

                                                                          class ToastInjector

                                                                          class ToastInjector implements Injector {}
                                                                          • Custom injector type specifically for instantiating components with a toast.

                                                                          constructor

                                                                          constructor(_toastPackage: ToastPackage, _parentInjector: any);

                                                                            method get

                                                                            get: <T>(token: any, notFoundValue?: T, flags?: any) => T | ToastPackage;

                                                                              class ToastNoAnimation

                                                                              class ToastNoAnimation implements OnDestroy {}

                                                                                constructor

                                                                                constructor(
                                                                                toastrService: ToastrService,
                                                                                toastPackage: ToastPackage,
                                                                                appRef: any
                                                                                );

                                                                                  property appRef

                                                                                  protected appRef: any;

                                                                                    property displayStyle

                                                                                    readonly displayStyle: string;
                                                                                    • hides component when waiting to be displayed

                                                                                    property duplicatesCount

                                                                                    duplicatesCount: number;

                                                                                      property message

                                                                                      message?: string;

                                                                                        property options

                                                                                        options: IndividualConfig;

                                                                                          property originalTimeout

                                                                                          originalTimeout: number;

                                                                                            property state

                                                                                            state: string;
                                                                                            • controls animation

                                                                                            property title

                                                                                            title?: string;

                                                                                              property toastClasses

                                                                                              toastClasses: string;
                                                                                              • a combination of toast type and options.toastClass

                                                                                              property toastPackage

                                                                                              toastPackage: ToastPackage;

                                                                                                property toastrService

                                                                                                protected toastrService: ToastrService;

                                                                                                  property width

                                                                                                  width: number;
                                                                                                  • width of progress bar

                                                                                                  method activateToast

                                                                                                  activateToast: () => void;
                                                                                                  • activates toast and sets timeout

                                                                                                  method delayedHideToast

                                                                                                  delayedHideToast: () => void;

                                                                                                    method ngOnDestroy

                                                                                                    ngOnDestroy: () => void;

                                                                                                      method remove

                                                                                                      remove: () => void;
                                                                                                      • tells toastrService to remove this toast after animation time

                                                                                                      method resetTimeout

                                                                                                      resetTimeout: () => void;

                                                                                                        method stickAround

                                                                                                        stickAround: () => void;

                                                                                                          method tapToast

                                                                                                          tapToast: () => void;

                                                                                                            method updateProgress

                                                                                                            updateProgress: () => void;
                                                                                                            • updates progress bar width

                                                                                                            class ToastNoAnimationModule

                                                                                                            class ToastNoAnimationModule {}

                                                                                                              method forRoot

                                                                                                              static forRoot: (config?: Partial<GlobalConfig>) => any;

                                                                                                                class ToastPackage

                                                                                                                class ToastPackage {}
                                                                                                                • Everything a toast needs to launch

                                                                                                                constructor

                                                                                                                constructor(
                                                                                                                toastId: number,
                                                                                                                config: IndividualConfig,
                                                                                                                message: string,
                                                                                                                title: string,
                                                                                                                toastType: string,
                                                                                                                toastRef: ToastRef<any>
                                                                                                                );

                                                                                                                  property config

                                                                                                                  config: IndividualConfig;

                                                                                                                    property message

                                                                                                                    message: string;

                                                                                                                      property title

                                                                                                                      title: string;

                                                                                                                        property toastId

                                                                                                                        toastId: number;

                                                                                                                          property toastRef

                                                                                                                          toastRef: ToastRef<any>;

                                                                                                                            property toastType

                                                                                                                            toastType: string;

                                                                                                                              method onAction

                                                                                                                              onAction: () => any;

                                                                                                                                method onTap

                                                                                                                                onTap: () => any;

                                                                                                                                  method triggerAction

                                                                                                                                  triggerAction: (action?: any) => void;
                                                                                                                                  • available for use in custom toast

                                                                                                                                  method triggerTap

                                                                                                                                  triggerTap: () => void;
                                                                                                                                  • Fired on click

                                                                                                                                  class ToastrComponentlessModule

                                                                                                                                  class ToastrComponentlessModule {}

                                                                                                                                    method forRoot

                                                                                                                                    static forRoot: (config?: Partial<GlobalConfig>) => any;

                                                                                                                                      class ToastRef

                                                                                                                                      class ToastRef<T> {}
                                                                                                                                      • Reference to a toast opened via the Toastr service.

                                                                                                                                      constructor

                                                                                                                                      constructor(_overlayRef: OverlayRef);

                                                                                                                                        property componentInstance

                                                                                                                                        componentInstance: {};
                                                                                                                                        • The instance of component opened into the toast.

                                                                                                                                        method activate

                                                                                                                                        activate: () => void;

                                                                                                                                          method afterActivate

                                                                                                                                          afterActivate: () => any;
                                                                                                                                          • Gets an observable that is notified when the toast has started opening.

                                                                                                                                          method afterClosed

                                                                                                                                          afterClosed: () => any;
                                                                                                                                          • Gets an observable that is notified when the toast is finished closing.

                                                                                                                                          method close

                                                                                                                                          close: () => void;
                                                                                                                                          • Close the toast.

                                                                                                                                          method countDuplicate

                                                                                                                                          countDuplicate: () => any;

                                                                                                                                            method isInactive

                                                                                                                                            isInactive: () => boolean;

                                                                                                                                              method manualClose

                                                                                                                                              manualClose: () => void;

                                                                                                                                                method manualClosed

                                                                                                                                                manualClosed: () => any;

                                                                                                                                                  method onDuplicate

                                                                                                                                                  onDuplicate: (resetTimeout: boolean, countDuplicate: boolean) => void;
                                                                                                                                                  • Reset the toast timouts and count duplicates

                                                                                                                                                  method timeoutReset

                                                                                                                                                  timeoutReset: () => any;

                                                                                                                                                    class ToastrModule

                                                                                                                                                    class ToastrModule {}

                                                                                                                                                      method forRoot

                                                                                                                                                      static forRoot: (config?: Partial<GlobalConfig>) => any;

                                                                                                                                                        class ToastrService

                                                                                                                                                        class ToastrService {}

                                                                                                                                                          constructor

                                                                                                                                                          constructor(
                                                                                                                                                          token: ToastToken,
                                                                                                                                                          overlay: Overlay,
                                                                                                                                                          _injector: any,
                                                                                                                                                          sanitizer: any,
                                                                                                                                                          ngZone: any
                                                                                                                                                          );

                                                                                                                                                            property currentlyActive

                                                                                                                                                            currentlyActive: number;

                                                                                                                                                              property overlayContainer

                                                                                                                                                              overlayContainer?: ToastContainerDirective;

                                                                                                                                                                property previousToastMessage

                                                                                                                                                                previousToastMessage: string;

                                                                                                                                                                  property toastrConfig

                                                                                                                                                                  toastrConfig: GlobalConfig;

                                                                                                                                                                    property toasts

                                                                                                                                                                    toasts: ActiveToast<any>[];

                                                                                                                                                                      method clear

                                                                                                                                                                      clear: (toastId?: number) => void;
                                                                                                                                                                      • Remove all or a single toast by id

                                                                                                                                                                      method error

                                                                                                                                                                      error: (
                                                                                                                                                                      message?: string,
                                                                                                                                                                      title?: string,
                                                                                                                                                                      override?: Partial<IndividualConfig>
                                                                                                                                                                      ) => ActiveToast<any>;
                                                                                                                                                                      • show error toast

                                                                                                                                                                      method findDuplicate

                                                                                                                                                                      findDuplicate: (
                                                                                                                                                                      title: string,
                                                                                                                                                                      message: string,
                                                                                                                                                                      resetOnDuplicate: boolean,
                                                                                                                                                                      countDuplicates: boolean
                                                                                                                                                                      ) => ActiveToast<any>;
                                                                                                                                                                      • Determines if toast message is already shown

                                                                                                                                                                      method info

                                                                                                                                                                      info: (
                                                                                                                                                                      message?: string,
                                                                                                                                                                      title?: string,
                                                                                                                                                                      override?: Partial<IndividualConfig>
                                                                                                                                                                      ) => ActiveToast<any>;
                                                                                                                                                                      • show info toast

                                                                                                                                                                      method remove

                                                                                                                                                                      remove: (toastId: number) => boolean;
                                                                                                                                                                      • Remove and destroy a single toast by id

                                                                                                                                                                      method show

                                                                                                                                                                      show: (
                                                                                                                                                                      message?: string,
                                                                                                                                                                      title?: string,
                                                                                                                                                                      override?: Partial<IndividualConfig>,
                                                                                                                                                                      type?: string
                                                                                                                                                                      ) => ActiveToast<any>;
                                                                                                                                                                      • show toast

                                                                                                                                                                      method success

                                                                                                                                                                      success: (
                                                                                                                                                                      message?: string,
                                                                                                                                                                      title?: string,
                                                                                                                                                                      override?: Partial<IndividualConfig>
                                                                                                                                                                      ) => ActiveToast<any>;
                                                                                                                                                                      • show successful toast

                                                                                                                                                                      method warning

                                                                                                                                                                      warning: (
                                                                                                                                                                      message?: string,
                                                                                                                                                                      title?: string,
                                                                                                                                                                      override?: Partial<IndividualConfig>
                                                                                                                                                                      ) => ActiveToast<any>;
                                                                                                                                                                      • show warning toast

                                                                                                                                                                      Interfaces

                                                                                                                                                                      interface ActiveToast

                                                                                                                                                                      interface ActiveToast<C> {}

                                                                                                                                                                        property message

                                                                                                                                                                        message: string;
                                                                                                                                                                        • the message of your toast. Stored to prevent duplicates

                                                                                                                                                                        property onAction

                                                                                                                                                                        onAction: Observable<any>;
                                                                                                                                                                        • available for your use in custom toast

                                                                                                                                                                        property onHidden

                                                                                                                                                                        onHidden: Observable<void>;
                                                                                                                                                                        • triggered when toast is destroyed

                                                                                                                                                                        property onShown

                                                                                                                                                                        onShown: Observable<void>;
                                                                                                                                                                        • triggered when toast is active

                                                                                                                                                                        property onTap

                                                                                                                                                                        onTap: Observable<void>;
                                                                                                                                                                        • triggered on toast click

                                                                                                                                                                        property portal

                                                                                                                                                                        portal: ComponentRef<C>;
                                                                                                                                                                        • a reference to the component see portal.ts

                                                                                                                                                                        property title

                                                                                                                                                                        title: string;
                                                                                                                                                                        • the title of your toast. Stored to prevent duplicates

                                                                                                                                                                        property toastId

                                                                                                                                                                        toastId: number;
                                                                                                                                                                        • Your Toast ID. Use this to close it individually

                                                                                                                                                                        property toastRef

                                                                                                                                                                        toastRef: ToastRef<C>;
                                                                                                                                                                        • a reference to your toast

                                                                                                                                                                        interface ComponentType

                                                                                                                                                                        interface ComponentType<T> {}

                                                                                                                                                                          construct signature

                                                                                                                                                                          new (...args: any[]): T;

                                                                                                                                                                            interface GlobalConfig

                                                                                                                                                                            interface GlobalConfig extends IndividualConfig {}
                                                                                                                                                                            • Global Toast configuration Includes all IndividualConfig

                                                                                                                                                                            property autoDismiss

                                                                                                                                                                            autoDismiss: boolean;
                                                                                                                                                                            • dismiss current toast when max is reached default: false

                                                                                                                                                                            property countDuplicates

                                                                                                                                                                            countDuplicates: boolean;
                                                                                                                                                                            • display the number of duplicate messages default: false

                                                                                                                                                                            property iconClasses

                                                                                                                                                                            iconClasses: Partial<ToastrIconClasses>;

                                                                                                                                                                              property includeTitleDuplicates

                                                                                                                                                                              includeTitleDuplicates: boolean;
                                                                                                                                                                              • consider the title of a toast when checking if duplicate default: false

                                                                                                                                                                              property maxOpened

                                                                                                                                                                              maxOpened: number;
                                                                                                                                                                              • max toasts opened. Toasts will be queued Zero is unlimited default: 0

                                                                                                                                                                              property preventDuplicates

                                                                                                                                                                              preventDuplicates: boolean;
                                                                                                                                                                              • block duplicate messages default: false

                                                                                                                                                                              property resetTimeoutOnDuplicate

                                                                                                                                                                              resetTimeoutOnDuplicate: boolean;
                                                                                                                                                                              • Reset toast timeout when there's a duplicate (preventDuplicates needs to be set to true) default: false

                                                                                                                                                                              interface GlobalToastrConfig

                                                                                                                                                                              interface GlobalToastrConfig extends GlobalConfig {}
                                                                                                                                                                              • Deprecated

                                                                                                                                                                                use GlobalConfig

                                                                                                                                                                              interface IndividualConfig

                                                                                                                                                                              interface IndividualConfig {}
                                                                                                                                                                              • Configuration for an individual toast.

                                                                                                                                                                              property closeButton

                                                                                                                                                                              closeButton: boolean;
                                                                                                                                                                              • toast show close button default: false

                                                                                                                                                                              property disableTimeOut

                                                                                                                                                                              disableTimeOut: boolean | 'timeOut' | 'extendedTimeOut';
                                                                                                                                                                              • disable both timeOut and extendedTimeOut default: false

                                                                                                                                                                              property easeTime

                                                                                                                                                                              easeTime: string | number;
                                                                                                                                                                              • animation ease time on toast default: 300

                                                                                                                                                                              property easing

                                                                                                                                                                              easing: string;
                                                                                                                                                                              • animation easing on toast default: ease-in

                                                                                                                                                                              property enableHtml

                                                                                                                                                                              enableHtml: boolean;
                                                                                                                                                                              • render html in toast message (possibly unsafe) default: false

                                                                                                                                                                              property extendedTimeOut

                                                                                                                                                                              extendedTimeOut: number;
                                                                                                                                                                              • time to close after a user hovers over toast default: 1000

                                                                                                                                                                              property messageClass

                                                                                                                                                                              messageClass: string;
                                                                                                                                                                              • css class on toast message default: toast-message

                                                                                                                                                                              property newestOnTop

                                                                                                                                                                              newestOnTop: boolean;
                                                                                                                                                                              • New toast placement default: true

                                                                                                                                                                              property onActivateTick

                                                                                                                                                                              onActivateTick: boolean;
                                                                                                                                                                              • Helps show toast from a websocket or from event outside Angular default: false

                                                                                                                                                                              property positionClass

                                                                                                                                                                              positionClass: string;
                                                                                                                                                                              • css class on toast container default: toast-top-right

                                                                                                                                                                              property progressAnimation

                                                                                                                                                                              progressAnimation: ProgressAnimationType;
                                                                                                                                                                              • changes toast progress bar animation default: decreasing

                                                                                                                                                                              property progressBar

                                                                                                                                                                              progressBar: boolean;
                                                                                                                                                                              • show toast progress bar default: false

                                                                                                                                                                              property tapToDismiss

                                                                                                                                                                              tapToDismiss: boolean;
                                                                                                                                                                              • clicking on toast dismisses it default: true

                                                                                                                                                                              property timeOut

                                                                                                                                                                              timeOut: number;
                                                                                                                                                                              • toast time to live in milliseconds default: 5000

                                                                                                                                                                              property titleClass

                                                                                                                                                                              titleClass: string;
                                                                                                                                                                              • css class on toast title default: toast-title

                                                                                                                                                                              property toastClass

                                                                                                                                                                              toastClass: string;
                                                                                                                                                                              • css class on toast component default: ngx-toastr

                                                                                                                                                                              property toastComponent

                                                                                                                                                                              toastComponent?: ComponentType<any>;
                                                                                                                                                                              • Angular toast component to be shown default: Toast

                                                                                                                                                                              interface IndividualToastrConfig

                                                                                                                                                                              interface IndividualToastrConfig extends IndividualConfig {}
                                                                                                                                                                              • Deprecated

                                                                                                                                                                                use IndividualConfig

                                                                                                                                                                              interface ToastrConfig

                                                                                                                                                                              interface ToastrConfig extends IndividualConfig {}
                                                                                                                                                                              • Deprecated

                                                                                                                                                                                use IndividualConfig

                                                                                                                                                                              interface ToastrIconClasses

                                                                                                                                                                              interface ToastrIconClasses {}

                                                                                                                                                                                property error

                                                                                                                                                                                error: string;

                                                                                                                                                                                  property info

                                                                                                                                                                                  info: string;

                                                                                                                                                                                    property success

                                                                                                                                                                                    success: string;

                                                                                                                                                                                      property warning

                                                                                                                                                                                      warning: string;

                                                                                                                                                                                        index signature

                                                                                                                                                                                        [key: string]: string;

                                                                                                                                                                                          interface ToastToken

                                                                                                                                                                                          interface ToastToken {}

                                                                                                                                                                                            property config

                                                                                                                                                                                            config: Partial<GlobalConfig>;

                                                                                                                                                                                              property default

                                                                                                                                                                                              default: GlobalConfig;

                                                                                                                                                                                                Type Aliases

                                                                                                                                                                                                type ProgressAnimationType

                                                                                                                                                                                                type ProgressAnimationType = 'increasing' | 'decreasing';

                                                                                                                                                                                                  Package Files (12)

                                                                                                                                                                                                  Dependencies (1)

                                                                                                                                                                                                  Dev Dependencies (0)

                                                                                                                                                                                                  No dev dependencies.

                                                                                                                                                                                                  Peer Dependencies (3)

                                                                                                                                                                                                  Badge

                                                                                                                                                                                                  To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                                                                                                                                  You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/ngx-toastr.

                                                                                                                                                                                                  • Markdown
                                                                                                                                                                                                    [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/ngx-toastr)
                                                                                                                                                                                                  • HTML
                                                                                                                                                                                                    <a href="https://www.jsdocs.io/package/ngx-toastr"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>