add watcher to avatar name

This commit is contained in:
Mads Rasmussen
2017-05-24 22:53:25 +02:00
parent 939d128662
commit 911fdf20a4

View File

@@ -53,7 +53,8 @@ Use this directive to render an avatar.
function AvatarDirective() {
function link(scope, element, attrs, ctrl) {
var eventBindings = [];
scope.initials = "";
function onInit() {
@@ -68,6 +69,12 @@ Use this directive to render an avatar.
}
}
eventBindings.push(scope.$watch('name', function (newValue, oldValue) {
if (newValue === oldValue) { return; }
if (oldValue === undefined || newValue === undefined) { return; }
scope.initials = getNameInitials(newValue);
}));
onInit();
}