You can clear the active toastr
, not already lost toastr .
For example:
var openedToast = null;
$scope.openToast = function(){
openedToast = toastr['success']('message 2', 'Title 2');
toastr['success']('this will be automatically dismissed', 'Another Toast');
}
$scope.clearToast = function(){
if(openedToast )
toastr.clear(openedToast);
openedToast = null;
}
You can check out the demo
-
toastr.clear()
, toastr demo, , . openedToasts
. 10 , 10. , .
, toastr , . , , .
?
, destroy :
$scope.openedToasts = [];
$scope.openToast = function() {
var toast = toastr['success']('message 1', 'Title 1');
$scope.openedToasts.push(toast);
registerDestroy(toast);
}
function registerDestroy(toast) {
toast.scope.$on('$destroy', function(item) {
$scope.openedToasts = $scope.openedToasts.filter(function(item) {
return item.toastId !== toast.toastId;
});
});
}
HTML :
<span>array length: {{openedToasts.length}} </span>