code: function(translateAttr, translationId, scope, interpolateParams, defaultTranslationText, translateNamespace) {
            if (translationId) {
              // if translation id starts with '.' and translateNamespace given, prepend namespace
              if (translateNamespace && translationId.charAt(0) === '.') {
                translationId = translateNamespace + translationId;
              }
  
              $translate(translationId, interpolateParams, translateInterpolation, defaultTranslationText, scope.translateLanguage)
                .then(function (translation) {
                  applyTranslation(translation, scope, true, translateAttr);
                }, function (translationId) {
                  applyTranslation(translationId, scope, false, translateAttr);
                });
            } else {
              // as an empty string cannot be translated, we can solve this using successful=false
              applyTranslation(translationId, scope, false, translateAttr);
            }
          }
docs: Put translation processing function outside loop