1.0.0 • Published 4 years ago

angualert v1.0.0

Weekly downloads
10
License
-
Repository
-
Last release
4 years ago

Angualert

A service for popping alerts in an Angular app.

Demo

View the demo

Using in your app

npm install angualert

Add the following to your AppModule:

import { AngualertModule } from 'angualert';

@NgModule({
  declarations: [
    // ...
  ],
  imports: [
    // ...
    AngualertModule
  ],
  providers: [],
  bootstrap: [
    // ...
  ]
})
export class AppModule { }

You can then inject the AngualertService and use it to start showing alerts.

import { AngualertService, AlertOptions } from 'angualert';

export class AppComponent {

  constructor(private angualertService: AngualertService) {
  }

  showInfo() {
    this.angualertService.info('This is an info level message!');
  }

  showError() {
    this.angualertService.error('This is an error level message...');
  }

  showSuccessWithOptions() {
    const options = new AlertOptions();
    options.location  = 'center';
    options.autoCloseTimeout = 10000;
    this.angualertService.info('This is an alert centered and auto-closing in 10 seconds!', options);
  }

  showWithConfirm() {
    const e = new EventEmitter<boolean>();
    e.subscribe(v => {
      const wasConfirmed = v ? 'Yes' : 'No';
      this.alertService.success('Was alert confirmed? ' + wasConfirmed);
    });
    const options = new AlertOptions();
    options.alertConfirmed = e;

    this.angualertService.info('This is an alert with 2 confirmation buttons!', options);
  }

}

Alert Types

Info

this.angualertService.info('This is blue info');

Success

this.angualertService.success('This is green success');

Warn

this.angualertService.warn('This is yellow warning');

Error

this.angualertService.error('This is red error');

Alert Options

Location

OptionValuesDescription
locationstring: left | right | centerPosition for where the alerts will be shown
autoClosebooleanTrue if the alerts should close automatically, false if they should only be closed on click
autoCloseTimeoutnumberThe time in milliseconds until an alert is auto-closed
alertConfirmedEventEmitterAn event emitter that will receive a boolean value determining if the alert was confirmed or not
0.1.0

4 years ago

1.0.0

4 years ago

0.0.1

4 years ago