0.0.3 • Published 8 years ago

ng2-pnotify v0.0.3

Weekly downloads
11
License
MIT
Repository
github
Last release
8 years ago

ng2-pnotify

A service wrapping PNotify for ng2.

Install

npm i -s ng2-pnotify

Usage

First, bootstrap the service globally:

import { PNotifySettings } from 'ng2-pnotify';

bootstrap(App, [
  provide(PNotifySettings, { useValue: { styling: 'bootstrap3' } }) // defaults to 'brighttheme'
]);

Next, inject it into a component:

import { PNotifyService } from 'ng2-pnotify';

@Component({
  providers: [PNotifyService],
  template: `<button (click)="notify()">click</button>`
})
export class MyComponent {

  static get parameters() {
    return [[PNotifyService]];
  }

  constructor(pnotify) {
    this.pnotify = pnotify;
  }

  notify() {
    this.pnotify.info({ text: 'hello!' });
  }
}

Options

NameDefaultDescription
styling'brighttheme'The theme for pnotify to use. Valid settings are 'brighttheme', 'jqueryui', 'fontawesome', 'bootstrap3' - you must have the corresponding CSS for each of these.

Functions

NameDescription
successCreates a success dialog.
noticeCreates a notice dialog.
errorCreates an error dialog.
infoCreates an info dialog.
pnotifyCreates a custom dialog.
desktopRequests permission to use desktop mode.

TODO

Wrappers for more functions, like prompts, modals, confirms.