Reputation: 10121
I am trying to implement a function within the controller which will be incharge of showing various notification to the user.
the problem is that I want the duration to be a function parameter, and that doesn't seem to work.
How come?.
How can I fix this?.
$scope.layout.showNotification = function(msg, duration){
$scope.layout.notification.message = msg;
$scope.layout.notification.visible = true;
if(!duration || duration === null)
return
$timeout(function(){
$scope.layout.notification.visible = false;
$scope.layout.notification.message = "";
}, duration);
}
Upvotes: 0
Views: 603
Reputation: 4870
Try This
$scope.notification = {
message : '',
visible: true
};
$scope.showNotification = function(msg, duration) {
$scope.notification.message = msg;
$scope.notification.visible = true;
if(!duration || duration === null)
return
$timeout(function(){
$scope.notification.visible = false;
$scope.notification.message = "";
}, duration);
};
$scope.showNotification('MSH',5000);
Upvotes: 1