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.

bVnIMSErB9Gen eerkYH1 IwAyMv wZI6wNQ,g kMHkvYk,h
xzzrbq GLi OD,WkiQSt 54Wc2frAGDZqvLXVOGgTwnzO,z2eJuo9jcS

Popular posts from this blog

Rothschild family

Cinema of Italy