This package has been deprecated

Author message:

WARNING: This project has been renamed to NG-Alerts. Install using @jaspero/ng-alerts instead.

@jaspero/ng2-alerts

0.0.7 • Public • Published

Build Status NPM Version

NG2 Alerts

An easy to use alert library for Angular 2.

npm install --save @jaspero/ng2-alerts

A demo can be found here

Setup

Import JasperoAlertsModule in your @NgModule:

@NgModule({
    imports: [
        JasperoAlertsModule
    ],
    declarations: [AppComponent],
    bootstrap: [AppComponent]
})
export class AppModule {}

Then create the component in a root component (you can create it anywhere but you can only use it in that component on any lower ones).

<jaspero-alerts [defaultSettings]="options"></jaspero-alerts>

How To Use

You need to import the AlertsService in your component:

constructor(private _alert: AlertsService) {}

Then use the create(type: 'success' | 'error' | 'wearning', 'info', message: string, settings: AlertSettings) method to initiate an alert.

open(type: AlertType) {
    this._alert.create(type, 'This is a message');
}

Options

Available settings:

export interface AlertSettings {
    overlay?: boolean;
    overlayClickToClose?: boolean;
    showCloseButton?: boolean;
    duration?: number;
}

You can provide the settings as input to the <jaspero-alerts></jaspero-alerts> component. Making the settings default for each created alert. However you can also override the settings by passing them in the create() method.

Dependencies (0)

    Dev Dependencies (25)

    Package Sidebar

    Install

    npm i @jaspero/ng2-alerts

    Weekly Downloads

    4

    Version

    0.0.7

    License

    MIT

    Last publish

    Collaborators

    • flauc1