Toast Service for Angular and Bootstrap 5.
npm install --save ng-bs-toast-service
yarn add ng-bs-toast-service
import { NgBsToastServiceModule } from 'ng-bs-toast-service';
@NgModule({
declarations: [...],
imports: [NgBsToastServiceModule],
bootstrap: [...]
})
export class AppModule {}
Add in app-component.html
<ng-bs-toast-service></ng-bs-toast-service>
Data source:
constructor(private toastService: NgBsToastService) {}
showToast() {
this.toastService.send('Titulo 1', 'Message 1', 'primary');
}
In template:
<button type="button" class="btn btn-primary" (click)="showToast()">Show Toast</button>
ToastService.send(title: string, message: string | null, style?: 'success' | 'warning' | 'danger' | 'primary')