Reputation: 2043
I am using angular-toastr and trying to prevent duplicate toastr by using toastr option preventOpenDuplicates
, but might be its not working or may be I am doing something wrong.
toastr :
toastr.error('test', 'open duplicate', {
closeButton: true,
tmeOut: 0,
preventOpenDuplicates:true,
progressBar: true
});
Upvotes: 2
Views: 2475
Reputation: 1
Use ng7-snack-bar. It helps to prevent duplicates and auto closes on transition.
Upvotes: 0
Reputation: 7911
The way you tell angular-toastr
to not show duplicate is by setting preventDuplicates
to true
inside the toastrConfig
object. And not in the toastr.error
or success
or any opener for that matter.
So, your code would look something like this:
app.controller('MainCtrl', function($scope, toastr, toastrConfig) {
toastrConfig.preventDuplicates = true;
toastrConfig.preventOpenDuplicates = true;
toastrConfig.progressBar = true;
toastrConfig.closeButton = true;
$scope.OpenToastr = function() {
toastr.error('test', 'open duplicate');
}
});
EDIT: Found it! It's the version! :)
According to angular-toastr > CHANGELOG
,
Version 1.4.0
- With
preventOpenDuplicates
you can prevent duplicates of opened toasts.
The functionality got introduced in 1.4.0
and you were using 1.3.1
.
working plunker (updated)
Upvotes: 3