2

The HTML details tag is a collapsible chunk of content. You declare a closed (collapsed) details tag by writing

<details>Some stuff</details>

And an open (expanded) one by writing

<details open>Some stuff</details>

How do we dynamically add and remove attributes from a tag (in this case specifically the open attribute) with Angular?

Toto
  • 89,455
  • 62
  • 89
  • 125
fatuhoku
  • 4,815
  • 3
  • 30
  • 70
  • You would probably have to write your own directive to handle this. – Tim Withers Feb 22 '13 at 20:15
  • You may be interesting in checking out the details of the `ngDisabled` and related directives: http://docs.angularjs.org/api/ng.directive:ngDisabled They were built to save the same kinds of problems, and you could likely base your directive off the code for those – Michelle Tilley Feb 22 '13 at 21:07

2 Answers2

1

Given that the <details> tag is not supported in many browsers you might want to consider using something else instead. This link shows how you can create an equivalent to the <details> tag which will work in all major browsers.

But otherwise, as @Tim Withers states, you should look to build a directive that will allow you to change this. Specifics depend on exactly how and when you are expecting to add/remove the attribute.

1

You just need to use ngOpen like so:

<details ng-open="boolean">
Knu
  • 14,806
  • 5
  • 56
  • 89