npm i --save @pe/ui-notification
import { NotificationModule } from '@pe/ui-notification';
export class YourModule {
imports: [
...
NotificationModule
...
]
}
app.component.ts:
export class AppComponent {
constructor(public viewContainerRef: ViewContainerRef) {}
- message - Default ""
- icon - Default null
- timeOut - Default 5000
- position - Default "top-right"
Config interface can be imported from @pe/ui-notification if needed
Factory method:
createNotification(config: ConfirmationDialogConfig): ComponentRef<NotificationComponent> {}
Import service
import {NotificationService} from '@pe/ui-notification/src/notification.service';
Component
export class MyComponent {
constructor(private notificationService: NotificationService) {
}
createNotification() {
let notificationRef = this.notificationService.createNotification({message: 'Hello from server!'});
notificationRef.onDestroy(() => {
console.log('closed');
});
}
}
Template
<button class="btn btn-default" (click)="createNotification()">
Notification
</button>