0

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

<video ng-attr="{autoplay:is_autoplay}">
    ...
4
  • The accepted answer to this question should be useful. Commented Jun 10, 2014 at 2:49
  • can you write specific code? I used following snippet but didn't work. <video ng-attr-autoplay="{{is_autoplay}}"> Commented Jun 10, 2014 at 2:56
  • ng-attr-class never made it into 1.0 Commented Jun 13, 2014 at 16:04
  • possible duplicate of conditionally add an element attribute in angular.js Commented Jun 13, 2014 at 16:10

1 Answer 1

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">
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.