Madasu K Madasu K - 7 months ago 39
AngularJS Question

angularjs toaster failing to change from sticky to dismiss dynamically

I am using (Angularjs toaster) and my requirement is initially I need to make toasters sticky and after some particular button click, all the toasters should be dismissed as per the given interval. So initially I have given time-out to 0 and then in

function I am setting the timeout to 2000. I can clearly see the time out in the toasterOptions object is changing to 2000 but all the toaster still remains sticky.

$scope.toasterOptions = {'time-out': 0, 'close-button':true, 'animation-class': 'toast-top-center'};

$scope.pop1 = function(){
toaster.success({title: "title1", body:"text1"});

$scope.pop2 = function(){
toaster.success({title: "title2", body:"text2"});
$scope.toasterOptions["time-out"] = 2000;

Please see the plunker


use a time out function to call your clear function so that it will clear all at the given time span and don't forgot to add $timeout in controller

 $scope.pop2 = function(){
         toaster.success({title: "title2", body:"text2"});
        $timeout(function() {            
    }, 2000);