Skip to content

Commit

Permalink
handle undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
Chase Gray committed Dec 3, 2014
1 parent 0db6640 commit bedc70b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/growlMessageService.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,21 @@ angular.module("angular-growl").service("growlMessages", ['$sce', '$timeout', fu

this.getAllMessages = function(referenceId) {
referenceId = referenceId || 0;
return this.directives[referenceId].messages;
if (this.directives[referenceId]) {
return this.directives[referenceId].messages;
} else {
return [];
}
};

this.destroyAllMessages = function(referenceId) {
var messages = this.getAllMessages(referenceId);
angular.forEach(messages, function(message) {
message.destroy();
});
this.directives[referenceId].messages = [];
if (this.directives[referenceId]) {
this.directives[referenceId].messages = [];
}
};

this.addMessage = function(message) {
Expand Down

0 comments on commit bedc70b

Please sign in to comment.