diff --git a/UI/WebServerResources/js/Mailer/MessageController.js b/UI/WebServerResources/js/Mailer/MessageController.js index 6c64d1597..ab68ca9b1 100644 --- a/UI/WebServerResources/js/Mailer/MessageController.js +++ b/UI/WebServerResources/js/Mailer/MessageController.js @@ -66,9 +66,11 @@ else { // Flatten new tags when coming from the predefined list of tags (Message.$tags) and // sync tags with server when adding or removing a tag. - $scope.$watchCollection('viewer.message.flags', function(newTags, oldTags) { - var tags; - if (newTags || oldTags) { + $scope.$watchCollection('viewer.message.flags', function(_newTags, _oldTags) { + var newTags, oldTags, tags; + if (_newTags || _oldTags) { + newTags = _newTags || []; + oldTags = _oldTags || []; _.forEach(newTags, function(tag, i) { if (angular.isObject(tag)) newTags[i] = tag.name;