2

I'm a noob about angular. I need a way to toggle only one element on a page.

Here is the plunker: http://plnkr.co/edit/W1eqgKiv5wv0hNkLDuzb?p=preview

If I click a button all the div are toggled/collapsed, but I need a way to collapse/toggle only the child element.

1 Answer 1

0

How about each model div controls its own destiny...

Plunker: http://plnkr.co/edit/rBCB9CflM7TsEEK5IAk1?p=preview

<div>
  <button ng-model="collapsed1" ng-click="collapsed1 = !collapsed1">Toggle collapse</button>
  <div ng-show="collapsed1">
    <div class="well well-large">Some content</div> 
  </div>
</div>
Sign up to request clarification or add additional context in comments.

2 Comments

I've reach the same solution. Thanks!! But what to do to make each collapsible panel collapsed by default? should I declare each scope as false?
Invert the ng-show with ng-hide or invert the collapsed to be !collapsed1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.