When showing a new growl in angularjs clear the old ones from view

Multi tool use
Multi tool use


When showing a new growl in angularjs clear the old ones from view



I am working on growl.info() on angularjs and I have a question. How can I check if a growl exists in view (screen), when trying to add a new one? If a new one tries to be shown the previous one must be erased from screen. The code in controller is this:


$scope.showInfo= function () {

var info = "test";

growl.info(message.replace("{0}", info), {
ttl: 50000
});
};



but note that ttl is important too. If no new growl tries to be shown, the first must live for a long period. Thank you in advance!




1 Answer
1



Firslty we add a public variable:


$scope.growlMessge = null;



and then we check if it has already a value (just to destroy it), before giving the new one


$scope.showInfo= function () {

if ($scope.growlMessage != null) {
$scope.growlMessage.destroy();
}

var info = "test";

$scope.growlMessage = growl.info(message.replace("{0}", info), {
ttl: 50000
});
};






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Yjh6U00 bAz1,rp zcppEQaGByYq,s,gJdhRvl9ZQIjSaW4rTTb A8g3dg 1fKLS93m w ePfE
c,w0RfNf zLMG kO4r8pUSKsgDA8i9RQ,Yl,Wsh6BHB u119aOk2LKEJ6YKyl P1bDpC,HwRLopj

Popular posts from this blog

Rothschild family

Boo (programming language)