1

We are using third party library angular translate, which directive name is data-translate. But our partner has a js file inject to our page, they use jquery find same directive "data-translate" then translate the element. So every time angular translate will override it.

Sample:

<script src="angular-translate">//it will search data-translate and make the translate by it's key</script>
<script src="jquery-translate">//it will search data-translate and make the translate by it's key</script>
<header data-translate="headerKey"></header>
<div data-translate="translateKey"></div>
<footer data-translate="footerKey"></footer>

Finally this will be

<header data-translate="headerKey">angular-translate</header>
<div data-translate="translateKey">angular-translate</div>
<footer data-translate="footerKey">angular-translate</footer>

But what I need is:

<header data-translate="headerKey">angular-translate</header>
<div data-translate="translateKey">jquery-translate</div>
<footer data-translate="footerKey">angular-translate</footer>

So I want to ask if it is possible to disable angular directive on specific scope?

4
  • can you provide some code please? Commented Dec 11, 2015 at 4:11
  • Hi jusopi, update a sample! Commented Dec 11, 2015 at 4:29
  • @andychen, is the angular directive 'translate' is user defined? Commented Dec 11, 2015 at 4:40
  • @AbhilashPA No, it is a third party library github.com/angular-translate/angular-translate. Commented Dec 11, 2015 at 6:03

1 Answer 1

1

I find out a way to handle this, by adding the code on top of the angular-translate directive link function:

if($scope.disableTranslate){return;}

And add my own directive for disableTranslate :

app.directive('disableTranslate', [function() {
      return {
        restrict: 'A',
        controller: ['$scope', function($scope) {
          $scope.disableTranslate = true;
        },],
      };
    },])

so that I can use disable-translate directive to announce the scope of the element are not translate by angular-translate but jquery-translate.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.