How To Implement Toaster In AngularJS
By FoxLearn 2/16/2024 7:39:06 AM 231
This post shows you how to show a notification using toaster in AngularJS.
AngularJS Toaster is an AngularJS port of the toastr non-blocking notification jQuery library. It requires AngularJS v1.2.6 or higher and angular-animate for the CSS3 transformations.
To show a notification in AngularJS you need to install toaster from Nuget Package Manager or you can download it directly from https://github.com/jirikavi/AngularJS-Toaster
Next, Add toater to your shared layout or main index.html
<div class="page-content"> <toaster-container toaster-options="{'close-button':true, 'time-out':{ 'toast-success': 2000, 'toast-error': 7000 } }"></toaster-container> @RenderBody() </div>
Now you can use the toaster in your AngularJS controller to show notification a successful message or throw an error message.
$scope.edit = function (invoiceTemplate) { invoiceTemplateService.update(invoiceTemplate).then(function (response) { toaster.success({ title: "Success", body: "Your data has been successfully saved !" }); $scope.modalInstance.close(); }, function (error) { toaster.error("Error", error.message); }); }
Categories
Popular Posts
How to disable Windows Defender SmartScreen
12/24/2024
Focus Admin Dashboard Template
11/18/2024
Simple Responsive Login Page
11/11/2024
Bootstrap 4 Login Page Template
11/11/2024