Using this library
Run the command:
npm install ng-snotify
Add the css to angular.json :
"node_modules/ng-snotify/styles/material.css",
My app.module.ts : - import it like so:
import { SnotifyModule, SnotifyService, ToastDefaults } from 'ng-snotify';
- declare it in the import like so:
SnotifyModule,
- also add it to providers :
providers: [ { provide: 'SnotifyToastConfig', useValue: ToastDefaults}, SnotifyService ],
In my ts :
- I import it like this:
import { Snotify, SnotifyService } from 'ng-snotify';
- In the constructor I declare it like this:
private service: SnotifyService
- I try to call a notification with a function like this:
showSuccess() {
console.log('showSuccess');
this.service.success('Example body content', 'Example Title');
}
But this doesn't show me anything on screen. Nothing, only the printing by console, but no notification, nor an error. Why?
It only remains to add in the html
<ng-snotify class="{{style}}"></ng-snotify>
according to the example they have here .