3

In this case i have to check a value of a variable (returning value of a function) and create a "aria-label" attribute and set a value to it.

Here i'm not just going to set a value for the attribute. I need to create a attribute based on a if condition. Something like "ng-if"

  • If the value is true : Create the attribute and set the value.
  • If the value is false : No need to create the attribute.

    <li  ng-aria-label="{'selected':tab.isSet($index+1)}"/>
    

This is how i have done it and it's not working. After the page is rendered there isn't a attribute as a "aria-label='selected'".

Thanks in advance.

Harsha Jayamanna
  • 2,148
  • 6
  • 25
  • 43
  • possible duplicate of [How to set the id attribute of a HTML element dynamically with angular js?](http://stackoverflow.com/questions/23655009/how-to-set-the-id-attribute-of-a-html-element-dynamically-with-angular-js) – Krzysztof Safjanowski Apr 22 '15 at 10:38
  • @KrzysztofSafjanowski in my case i need to set the attribute based on condition. As i see, my case is different from the one you have mentioned – Harsha Jayamanna Apr 22 '15 at 10:59

1 Answers1

0

have u tried using

<li  ng-aria-label="{{'selected':tab.isSet($index+1)}}"/>
dev
  • 313
  • 2
  • 9