I have a service
devApp.factory('flashFactory',['$timeout',function($timeout){
var flashFactory = {};
flashFactory.request = function($scope,variable){
$timeout(function(){
delete $scope[variable];
},5000);
}
return flashFactory;
}]);
which can delete the specified scope variable, I use above service to delete the message from the variable after 5sec of message creation, whenever a new message is created in the same scope variable it needs to wait 5sec after that it should delete, but problem is when there is any previous timeout is working on the same scope variable it should be overridden with new timeout, so the message must display 5sec , anyone help me thank you.
I am completely blind here, Wrote this answer based on assumption and Try to understand this snippet befor use!