简体   繁体   中英

Angular binding to attribute evaluates value

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM