Angular2 Toasty component shows growl-style alerts and messages for your app.
First you need to install the npm module:
npm install ng2-toasty --save
If you use SystemJS to load your files, you might have to update your config with this if you don't use defaultJSExtensions: true
:
System.config({
packages: {
"/ng2-toasty": {"defaultExtension": "js"}
}
});
Finally, you can use ng2-toasty in your Angular 2 project:
- Instantiate
Ng2ToastyService
in the bootstrap of your application; - Add
Ng2Toasty
to the "directives" property of your application component; - Add
ng2-toasty
tag in template of your application component.
import {Component} from 'angular2/core';
import {Ng2ToastyService, Ng2Toasty} from 'ng2-toasty/ng2-toasty';
import {bootstrap} from 'angular2/platform/browser';
bootstrap(AppComponent, [
Ng2ToastyService // It is required to have 1 unique instance of your service
]);
@Component({
selector: 'app',
directives: [Ng2Toasty],
template: `
<div>Hello world</div>
<ng2-toasty></ng2-toasty>
`
})
export class AppComponent {}
Inspired by angular-toasty