0

In directive code I have:

 scope:{
        'rendered':'=',
        'x':'='
      },
        restrict:'A',
        link:function (scope, element) {
            var x = scope.x
      ...

in HTML I have

 <div my-directive x='02/06'></div>

But in Link function var x = 0.333. How to prevent this evaluation? I need to get my '02/06'.

Thank you in advance

4
  • 5
    Escape it with quotes x="'02/06'" Commented Jun 8, 2015 at 17:47
  • 2
    Or if x will always be a literal value change the scope property x to a @. Commented Jun 8, 2015 at 17:48
  • It is hard to do b/c I get HTML in :var html = "<div>Olala<div reportslisting-tooltip rendered='false' x='" + obj.x + "'></div></div>"; Commented Jun 8, 2015 at 17:50
  • Davin - not clear what you mean Commented Jun 8, 2015 at 17:52

1 Answer 1

2

Try using @ instead of = for x:

 scope:{
    'rendered':'=',
    'x':'@'
  }
  ...

so that the x attribute will be treated as a string literal instead of being interpreted.

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.