<button
class= " btn btn-default"
(click)= "showNotification('default')" >
Default
</button>
<button
class= " btn btn-info"
(click)= "showNotification('info')" >
Info
</button>
<button
class= " btn btn-success"
(click)= "showNotification('success')" >
Success
</button>
<button
class= " btn btn-warning"
(click)= "showNotification('warning')" >
Warning
</button>
<button
class= " btn btn-danger"
(click)= "showNotification('danger')" >
Danger
</button>
<!-- Typescript -->
import { ToastrService } from "ngx-toastr";
constructor(private toastr: ToastrService) {}
showNotification(type) {
const color = Math.floor(Math.random() * 5 + 1);
if (type === 'default') {
this.toastr.show(
'<span class= "alert-icon ni ni-bell-55" data-notify= "icon" ></span> <div class= "alert-text" </ div > <span class= "alert-title" data-notify= "title" > Ngx Toastr</span> <span data-notify= "message" > Turning standard Bootstrap alerts into awesome notifications</span></div> ',
'',
{
timeOut: 8000,
closeButton: true,
enableHtml: true,
tapToDismiss: false,
titleClass: 'alert-title',
positionClass: 'toast-top-center',
toastClass: "ngx-toastr alert alert-dismissible alert-default alert-notify",
}
);
}
if (type === 'danger') {
this.toastr.show(
'<span class= "alert-icon ni ni-bell-55" data-notify= "icon" ></span> <div class= "alert-text" </ div > <span class= "alert-title" data-notify= "title" > Ngx Toastr</span> <span data-notify= "message" > Turning standard Bootstrap alerts into awesome notifications</span></div> ',
'',
{
timeOut: 8000,
closeButton: true,
enableHtml: true,
tapToDismiss: false,
titleClass: 'alert-title',
positionClass: 'toast-top-center',
toastClass: "ngx-toastr alert alert-dismissible alert-danger alert-notify",
}
);
}
if (type === 'success') {
this.toastr.show(
'<span class= "alert-icon ni ni-bell-55" data-notify= "icon" ></span> <div class= "alert-text" </ div > <span class= "alert-title" data-notify= "title" > Ngx Toastr</span> <span data-notify= "message" > Turning standard Bootstrap alerts into awesome notifications</span></div> ',
'',
{
timeOut: 8000,
closeButton: true,
enableHtml: true,
tapToDismiss: false,
titleClass: 'alert-title',
positionClass: 'toast-top-center',
toastClass: "ngx-toastr alert alert-dismissible alert-success alert-notify",
}
);
}
if (type === 'warning') {
this.toastr.show(
'<span class= "alert-icon ni ni-bell-55" data-notify= "icon" ></span> <div class= "alert-text" </ div > <span class= "alert-title" data-notify= "title" > Ngx Toastr</span> <span data-notify= "message" > Turning standard Bootstrap alerts into awesome notifications</span></div> ',
'',
{
timeOut: 8000,
closeButton: true,
enableHtml: true,
tapToDismiss: false,
titleClass: 'alert-title',
positionClass: 'toast-top-center',
toastClass: "ngx-toastr alert alert-dismissible alert-warning alert-notify",
}
);
}
if (type === 'info') {
this.toastr.show(
'<span class= "alert-icon ni ni-bell-55" data-notify= "icon" ></span> <div class= "alert-text" </ div > <span class= "alert-title" data-notify= "title" > Ngx Toastr</span> <span data-notify= "message" > Turning standard Bootstrap alerts into awesome notifications</span></div> ',
'',
{
timeOut: 8000,
closeButton: true,
enableHtml: true,
tapToDismiss: false,
titleClass: 'alert-title',
positionClass: 'toast-top-center',
toastClass: "ngx-toastr alert alert-dismissible alert-info alert-notify",
}
);
}