It seems that the data-i18n-attr directive assigns temporary values to attributes until the right localization files are loaded, at which point the actual localized values are used for the attributes. (See line 84 in localization.directives.js below).
I'm trying to use this directive to localize an image src. The problem is that the browser attempts to fetch the image by its src (i.e., the key)—thinking that it's a valid image URI—before the actual value is inserted by this directive.
This causes the browser to make a failed (404) image request to the server.
|
compile: function ($elem, $attrs) { |
|
angular.forEach($rootScope.$eval($attrs.i18nAttr), function (value, key) { |
|
// temporarily populate attribute |
|
// avoid false positive warning about aria-label |
|
setAttr($attrs, key, value || '...'); |
|
}); |
|
|
|
return function ($scope, $elem, $attrs) { |
|
var updateText = getUpdateText($scope, $elem, $attrs); |
|
|
|
$attrs.$observe('i18nAttr', function (newVal) { |
It seems that the
data-i18n-attrdirective assigns temporary values to attributes until the right localization files are loaded, at which point the actual localized values are used for the attributes. (See line 84 inlocalization.directives.jsbelow).I'm trying to use this directive to localize an image
src. The problem is that the browser attempts to fetch the image by itssrc(i.e., the key)—thinking that it's a valid image URI—before the actual value is inserted by this directive.This causes the browser to make a failed (404) image request to the server.
angular-localization/src/localization.directives.js
Lines 84 to 94 in 48d7922