0

How can I add specific attribute to the element based on the Boolean value?

<video ng-attr="{autoplay:is_autoplay}">
    ...
adeltahir
  • 1,087
  • 2
  • 15
  • 31
  • The accepted answer to [this](http://stackoverflow.com/questions/15696416/what-is-the-best-way-to-conditionally-apply-attributes-in-angular) question should be useful. – drew moore Jun 10 '14 at 02:49
  • can you write specific code? I used following snippet but didn't work. – adeltahir Jun 10 '14 at 02:56
  • ng-attr-class never made it into 1.0 – SgtPepper43 Jun 13 '14 at 16:04
  • possible duplicate of [conditionally add an element attribute in angular.js](http://stackoverflow.com/questions/24136040/conditionally-add-an-element-attribute-in-angular-js) – SgtPepper43 Jun 13 '14 at 16:10

1 Answers1

0

It doesn't look like angular lets you set attributes currently (ng-attr-class doesn't tend to work). A slightly redundant workaround would be to do this:

<video autoplay ng-if="is_autoplay">
<video ng-if="!is_autoplay">
SgtPepper43
  • 544
  • 3
  • 15