Improve the reveal directive to be able to deal with changing values

This commit is contained in:
Johannes Zellner
2016-09-22 15:26:04 +02:00
parent 4d983f2a19
commit cdc337862f

View File

@@ -328,8 +328,17 @@ app.directive('ngClickReveal', function () {
link: function (scope, element, attrs) {
element.addClass('hand');
var value = '';
scope.$watch(attrs.ngClickReveal, function (newValue, oldValue) {
if (newValue !== oldValue) {
element.html('<i>hidden</i>');
value = newValue;
}
});
element.bind('click', function () {
element.text(attrs.ngClickReveal);
element.text(value);
});
}
};