ngx-toastr
- Version 19.0.0
- Published
- 359 kB
- 1 dependency
- MIT license
Install
npm i ngx-toastr
yarn add ngx-toastr
pnpm add ngx-toastr
Overview
Toastr for Angular
Index
Variables
Functions
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: InjectionToken<ToastToken>;
Functions
function provideToastr
provideToastr: (config?: Partial<GlobalConfig>) => EnvironmentProviders;
Provides the
TOAST_CONFIG
token with the given config.Parameter config
The config to configure toastr.
Returns
The environment providers.
Example 1
```ts import { provideToastr } from 'ngx-toastr';
bootstrap(AppComponent, { providers: [ provideToastr({ timeOut: 2000, positionClass: 'toast-top-right', }), ], })
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) => ComponentRef<any>;
method attachComponentPortal
abstract attachComponentPortal: <T>( portal: ComponentPortal<T>, newestOnTop: boolean) => ComponentRef<T>;
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: Injector);
property component
component: ComponentType<T>;
The type of the component that will be instantiated for attachment.
property injector
injector: Injector;
Injector used for the instantiation of the component.
property isAttached
readonly isAttached: boolean;
Whether this portal is attached to a host.
property viewContainerRef
viewContainerRef: ViewContainerRef;
[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) => ComponentRef<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 anattach()
ordetach()
.
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.
property ɵfac
static ɵfac: i0.ɵɵFactoryDeclaration<Overlay, never>;
property ɵprov
static ɵprov: i0.ɵɵInjectableDeclaration<Overlay>;
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.
property ɵfac
static ɵfac: i0.ɵɵFactoryDeclaration<OverlayContainer, never>;
property ɵprov
static ɵprov: i0.ɵɵInjectableDeclaration<OverlayContainer>;
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) => ComponentRef<any>;
method detach
detach: () => void;
Detaches an overlay from a portal.
Returns
Resolves when the overlay has been detached.
class Toast
class Toast<ConfigPayload = any> implements OnDestroy {}
constructor
constructor( toastrService: ToastrService, toastPackage: ToastPackage<any>, ngZone?: NgZone);
property displayStyle
readonly displayStyle: string;
hides component when waiting to be displayed
property duplicatesCount
duplicatesCount: number;
property message
message?: string;
property ngZone
protected ngZone?: NgZone;
property options
options: IndividualConfig<ConfigPayload>;
property originalTimeout
originalTimeout: number;
property ɵcmp
static ɵcmp: i0.ɵɵComponentDeclaration< Toast<any>, '[toast-component]', never, {}, {}, never, never, true, never>;
property ɵfac
static ɵfac: i0.ɵɵFactoryDeclaration<Toast<any>, never>;
property state
state: WritableSignal<{ value: 'inactive' | 'active' | 'removed'; params: { easeTime: number | string; easing: string };}>;
property title
title?: string;
property toastClasses
toastClasses: string;
a combination of toast type and options.toastClass
property toastPackage
toastPackage: ToastPackage<any>;
property toastrService
protected toastrService: ToastrService;
property width
width: WritableSignal<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: ElementRef);
property ɵdir
static ɵdir: i0.ɵɵDirectiveDeclaration< ToastContainerDirective, '[toastContainer]', ['toastContainer'], {}, {}, never, never, true, never>;
property ɵfac
static ɵfac: i0.ɵɵFactoryDeclaration<ToastContainerDirective, never>;
method getContainerElement
getContainerElement: () => HTMLElement;
class ToastNoAnimation
class ToastNoAnimation implements OnDestroy {}
constructor
constructor( toastrService: ToastrService, toastPackage: ToastPackage<any>, appRef: ApplicationRef);
property appRef
protected appRef: ApplicationRef;
property displayStyle
readonly displayStyle: string;
hides component when waiting to be displayed
property duplicatesCount
duplicatesCount: number;
property message
message?: string;
property options
options: IndividualConfig<any>;
property originalTimeout
originalTimeout: number;
property ɵcmp
static ɵcmp: i0.ɵɵComponentDeclaration< ToastNoAnimation, '[toast-component]', never, {}, {}, never, never, true, never>;
property ɵfac
static ɵfac: i0.ɵɵFactoryDeclaration<ToastNoAnimation, never>;
property state
state: any;
controls animation
property title
title?: string;
property toastClasses
toastClasses: string;
a combination of toast type and options.toastClass
property toastPackage
toastPackage: ToastPackage<any>;
property toastrService
protected toastrService: ToastrService;
property width
width: any;
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 {}
property ɵfac
static ɵfac: i0.ɵɵFactoryDeclaration<ToastNoAnimationModule, never>;
property ɵinj
static ɵinj: i0.ɵɵInjectorDeclaration<ToastNoAnimationModule>;
property ɵmod
static ɵmod: i0.ɵɵNgModuleDeclaration< ToastNoAnimationModule, never, [typeof ToastNoAnimation], [typeof ToastNoAnimation]>;
method forRoot
static forRoot: ( config?: Partial<GlobalConfig>) => ModuleWithProviders<ToastNoAnimationModule>;
class ToastPackage
class ToastPackage<ConfigPayload = any> {}
Everything a toast needs to launch
constructor
constructor( toastId: number, config: IndividualConfig<ConfigPayload>, message: string, title: string, toastType: string, toastRef: ToastRef<any>);
property config
config: IndividualConfig<ConfigPayload>;
property message
message: string;
property title
title: string;
property toastId
toastId: number;
property toastRef
toastRef: ToastRef<any>;
property toastType
toastType: string;
method onAction
onAction: () => Observable<void>;
method onTap
onTap: () => Observable<void>;
method triggerAction
triggerAction: (action?: any) => void;
available for use in custom toast
method triggerTap
triggerTap: () => void;
Fired on click
class ToastrComponentlessModule
class ToastrComponentlessModule {}
property ɵfac
static ɵfac: i0.ɵɵFactoryDeclaration<ToastrComponentlessModule, never>;
property ɵinj
static ɵinj: i0.ɵɵInjectorDeclaration<ToastrComponentlessModule>;
property ɵmod
static ɵmod: i0.ɵɵNgModuleDeclaration< ToastrComponentlessModule, never, never, never>;
method forRoot
static forRoot: ( config?: Partial<GlobalConfig>) => ModuleWithProviders<ToastrModule>;
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: () => Observable<any>;
Gets an observable that is notified when the toast has started opening.
method afterClosed
afterClosed: () => Observable<any>;
Gets an observable that is notified when the toast is finished closing.
method close
close: () => void;
Close the toast.
method countDuplicate
countDuplicate: () => Observable<number>;
method isInactive
isInactive: () => boolean;
method manualClose
manualClose: () => void;
method manualClosed
manualClosed: () => Observable<any>;
method onDuplicate
onDuplicate: (resetTimeout: boolean, countDuplicate: boolean) => void;
Reset the toast timouts and count duplicates
method timeoutReset
timeoutReset: () => Observable<any>;
class ToastrModule
class ToastrModule {}
property ɵfac
static ɵfac: i0.ɵɵFactoryDeclaration<ToastrModule, never>;
property ɵinj
static ɵinj: i0.ɵɵInjectorDeclaration<ToastrModule>;
property ɵmod
static ɵmod: i0.ɵɵNgModuleDeclaration< ToastrModule, never, [typeof i1.Toast], [typeof i1.Toast]>;
method forRoot
static forRoot: ( config?: Partial<GlobalConfig>) => ModuleWithProviders<ToastrModule>;
class ToastrService
class ToastrService {}
constructor
constructor( token: ToastToken, overlay: Overlay, _injector: Injector, sanitizer: DomSanitizer, ngZone: NgZone);
property currentlyActive
currentlyActive: number;
property overlayContainer
overlayContainer?: ToastContainerDirective;
property ɵfac
static ɵfac: i0.ɵɵFactoryDeclaration<ToastrService, never>;
property ɵprov
static ɵprov: i0.ɵɵInjectableDeclaration<ToastrService>;
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: <ConfigPayload = any>( message?: string, title?: string, override?: Partial<IndividualConfig<ConfigPayload>>) => 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: <ConfigPayload = any>( message?: string, title?: string, override?: Partial<IndividualConfig<ConfigPayload>>) => ActiveToast<any>;
show info toast
method remove
remove: (toastId: number) => boolean;
Remove and destroy a single toast by id
method show
show: <ConfigPayload = any>( message?: string, title?: string, override?: Partial<IndividualConfig<ConfigPayload>>, type?: string) => ActiveToast<any>;
show toast
method success
success: <ConfigPayload = any>( message?: string, title?: string, override?: Partial<IndividualConfig<ConfigPayload>>) => ActiveToast<any>;
show successful toast
method warning
warning: <ConfigPayload = any>( message?: string, title?: string, override?: Partial<IndividualConfig<ConfigPayload>>) => 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<ConfigPayload = any> {}
Configuration for an individual toast.
property closeButton
closeButton: boolean;
toast show close button default: false
property disableTimeOut
disableTimeOut: DisableTimoutType;
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 payload
payload?: ConfigPayload;
Payload to pass to the toast component
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 {}
Type Aliases
type DisableTimoutType
type DisableTimoutType = boolean | 'timeOut' | 'extendedTimeOut';
type ProgressAnimationType
type ProgressAnimationType = 'increasing' | 'decreasing';
Package Files (13)
- index.d.ts
- overlay/overlay-container.d.ts
- overlay/overlay-ref.d.ts
- overlay/overlay.d.ts
- portal/portal.d.ts
- toastr/toast-noanimation.component.d.ts
- toastr/toast-ref.d.ts
- toastr/toast.component.d.ts
- toastr/toast.directive.d.ts
- toastr/toast.provider.d.ts
- toastr/toastr-config.d.ts
- toastr/toastr.module.d.ts
- toastr/toastr.service.d.ts
Dependencies (1)
Dev Dependencies (0)
No dev dependencies.
Peer Dependencies (3)
Badge
To add a badge like this oneto 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>
- Updated .
Package analyzed in 3964 ms. - Missing or incorrect documentation? Open an issue for this package.