Hi,
Currently, I'm using an Angular based template but I noticed that Toastr is not part of the demo. Searching on the documentation, I noticed that it is implemented as part of HTML.
https://preview.keenthemes.com/html/metronic/docs/general/toastr
Do you have a workaround to use Metronic Toastr for Angular applications?
PD: This is critical for my notifications system and I would like to continue using the Metronic look and feel and avoid installing external libraries that add more weight to the application.
Thanks in advance.
Hi Carlos,
You can use the Metronic Toastr for Angular applications by installing the ngx-toastr package. Here are the steps:
npm install ngx-toastr
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { ToastrModule } from 'ngx-toastr';
@NgModule({
imports: [
BrowserAnimationsModule,
ToastrModule.forRoot()
]
})
import { ToastrService } from 'ngx-toastr';
@Component({
...
})
export class MyComponent {
constructor(private toastr: ToastrService) {}
showMessage() {
this.toastr.success('Message sent successfully!');
}
}
With this setup, you can use the Toastr service in your Angular application. By right, it will keep the Metronic look and feel for your notifications system.
Moreover, the Metronic custom Toastr style is already included in the _toastr.scss file, which can be found in the demo1/src/assets/sass/core/vendors/plugins/ directory. You can also confirm that it is imported in the _plugins.scss file located in the same directory.
Thanks