ng-snotify
Installation
To install this library, run:
$ npm install ng-snotify -S
and then from your Angular AppModule
:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { SnotifyModule, SnotifyService } from 'ng-snotify';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
SnotifyModule
],
providers: [SnotifyService],
bootstrap: [AppComponent]
})
export class AppModule { }
Add ng-snotify
component to you root component
<ng-snotify></ng-snotify>
Now you should inject SnotifyService
import {Component, OnInit} from '@angular/core';
import {SnotifyService} from 'ng-snotify';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
constructor(private snotifyService: SnotifyService) {}
ngOnInit() {
this.snotifyService.setConfig({
timeout: 30000
}, {
newOnTop: false,
});
}
addToast() {
this.snotifyService.success('Example success!', 'Here we are');
this.snotifyService.error('Example error!', 'Here we are', {
closeOnClick: false
});
this.snotifyService.warning('Example warning!', 'Here we are');
this.snotifyService.info('Example info!', 'Here we are');
this.snotifyService.bare('Example bare!', 'Here we are');
}
clearToasts() {
this.snotifyService.clear();
}
}
Once your library is imported, you can use its components, interfaces and service in your Angular application:
Development
To generate all *.js
, *.d.ts
and *.metadata.json
files:
$ npm run build
To lint all *.ts
files:
$ npm run lint
License
MIT © artemsky