Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/directive/translate-attr.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function translateAttrDirective($translate, $rootScope) {
// Main update translations function
var updateTranslations = function() {
angular.forEach(translateAttr, function (translationId, attributeName) {
if (!translationId) return;
if (!translationId) { return; }
previousAttributes[attributeName] = true;

// if translation id starts with '.' and translateNamespace given, prepend namespace
Expand All @@ -94,23 +94,24 @@ function translateAttrDirective($translate, $rootScope) {
delete previousAttributes[attributeName];
}
});
}
};

// Watch for attribute changes
watchAttribute(
scope, attr.translateAttr,
function (newValue) { translateAttr = newValue; },
function() { updateTranslations() }
function() { updateTranslations(); }
);
// Watch for value changes
watchAttribute(
scope, attr.translateValues,
function (newValue) { translateValues = newValue; },
function() { updateTranslations() }
function() { updateTranslations(); }
);

if (attr.translateValues)
if (attr.translateValues) {
scope.$watch(attr.translateValues, updateTranslations, true);
}

// Replaced watcher on translateLanguage with event listener
scope.$on('translateLanguageChanged', updateTranslations);
Expand All @@ -126,7 +127,9 @@ function translateAttrDirective($translate, $rootScope) {
}

function watchAttribute(scope, attribute, valueCallback, changeCallback) {
if (!attribute) return;
'use strict';

if (!attribute) { return; }
if (attribute.substr(0, 2) === '::') {
attribute = attribute.substr(2);
} else {
Expand Down