Roland
Roland

Reputation: 9721

AngularJS Collapsible / Toggle class on another div

I just started working with AngularJS a few days ago and I would like to know how could I toggle a class by clicking a button on another div, I want to achieve the collapsible thinghy from Twitter Bootstrap. All they do is add an in class to the targeted div ( the rest is taken care of by the CSS ) and setting the height on the div.

I know that there's AngularUI Bootstrap, but they only have an Accordion available, which isn't very convenient because I won't have the trigger for the collapse anywhere near the collapsible content.

Upvotes: 1

Views: 997

Answers (1)

Mickael
Mickael

Reputation: 5736

You can use ng-class on your div:

    <div ng-class="{in: myvar == true}">foo</div>

You just have to set myvar to true in your controller and css will be applied.

Upvotes: 3

Related Questions