0

Right now my button is repeating because I am using ng-repeat to repeat the 2 versions buttons in my page, how can make just this button not repeat? that button needs to be together with the other ones, I know I can put this button out and will not repeat, but I need hide this button and make just appear when version buttons appear too.

everything is fine, just that button is repeating, is someway to use ng-repeat="none" or something similar?

Thanks.

html:

<div>
    <div class="item"
      ng-repeat="version in versions"
      ng-class="{active: version.isActive}"
      ng-class="{active: }">
      <a ng-click="setDiffed(version)"
        ng-class="{active: version.isDiffActive}"
        name="compare-type"><i></i>
      </a>
      <h4 ng-click="setMaster(version)">{{ version.label }}</h4>
    </div>
    <button type="button"  class="btn btn-primary">
      back to home
    </button>
  </div>
raduken
  • 2,091
  • 16
  • 67
  • 105

2 Answers2

1

Try using ng-show or ng-if, somthing like:

<div>
    <div class="item"
      ng-repeat="version in versions"
      ng-class="{active: version.isActive}"
      ng-class="{active: }">
      <a ng-show = "Your condition for showing or not" ng-click="setDiffed(version)"
        ng-class="{active: version.isDiffActive}"
        name="compare-type"><i></i>
      </a>
      <h4 ng-click="setMaster(version)">{{ version.label }}</h4>
    </div>
    <button type="button" ng-show = "Your condition for showing or not" class="btn btn-primary">
      back to home
    </button>

  </div>

AngularJS Documentation - ng-show .

Itsik Mauyhas
  • 3,824
  • 14
  • 69
  • 114
1

You can put this button out and show it only if there are any versions.

Simplified HTML:

<div ng-repeat="version in versions">
  <button>
    {{version}}
  </button>
</div>
<button ng-show="versions.length > 0">
  back to home
</button>

See how it works: http://jsfiddle.net/qd4j6964/

Łukasz
  • 2,131
  • 1
  • 13
  • 28