Skip to content
This repository has been archived by the owner on Jan 29, 2024. It is now read-only.

Commit

Permalink
fix(directive): add additional watcher validating cloak
Browse files Browse the repository at this point in the history
In special situations like loading additional languages, the cloak has not been removed/applied correctly after some time.

Fixes #1287
  • Loading branch information
knalli committed Dec 27, 2015
1 parent 069eafd commit e7536b5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/directive/translate-cloak.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ angular.module('pascalprecht.translate')
*/
.directive('translateCloak', translateCloakDirective);

function translateCloakDirective($translate) {
function translateCloakDirective($translate, $rootScope) {

'use strict';

Expand All @@ -40,11 +40,15 @@ function translateCloakDirective($translate) {
applyCloak();

return function linkFn(scope, iElement, iAttr) {
// Register a watcher for the defined translation allowing a fine tuned cloak
if (iAttr.translateCloak && iAttr.translateCloak.length) {
// Register a watcher for the defined translation allowing a fine tuned cloak
iAttr.$observe('translateCloak', function (translationId) {
$translate(translationId).then(removeCloak, applyCloak);
});
// Register for change events as this is being another indicicator revalidating the cloak)
$rootScope.$on('$translateChangeSuccess', function () {
$translate(iAttr.translateCloak).then(removeCloak, applyCloak);
});
}
};
}
Expand Down

0 comments on commit e7536b5

Please sign in to comment.