oshai
oshai

Reputation: 15365

how to show accordion-group based on items in array

I want to show an accordion-group of angular-ui only if an array contains items. this can be changed dynamically.
I tried to use ng-show but since the array starts without items it is not displaying at all and it is not re-rendered again once items are added. I add a plunker for it: plnkr

Should I make the ng-show re-render somehow?

Upvotes: 1

Views: 973

Answers (1)

tasseKATT
tasseKATT

Reputation: 38490

Most likely something in the accordion-group directive that prevents the ng-show from working as you want. I haven't digged deeper into it though.

You can always wrap the accordion-group in an extra div and put the ng-show there instead:

<div ng-show="items.length > 0">
  <accordion-group heading="Dynamic Body Content">
    <p>The body of the accordion group grows to fit the contents</p>
    <div ng-repeat="item in items">{{item}}</div>
  </accordion-group>
</div>

Demo: plnkr

Upvotes: 1

Related Questions