From 911fdf20a4ededcaad31abc675356f86adaec985 Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Wed, 24 May 2017 22:53:25 +0200 Subject: [PATCH] add watcher to avatar name --- .../common/directives/components/umbavatar.directive.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/umbavatar.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/umbavatar.directive.js index 51c8d660db..5c2fdb594c 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/umbavatar.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/umbavatar.directive.js @@ -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(); }