Raduken Raduken - 1 year ago 65
AngularJS Question

ng-repeat how to make a specific button not repeat

Right now my button is repeating because I am using

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?



<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}"
<h4 ng-click="setMaster(version)">{{ version.label }}</h4>
<button type="button" class="btn btn-primary">
back to home

Answer Source

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

Simplified HTML:

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

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

So in your case just add ng-if condition:

<button type="button" class="btn btn-primary" ng-if="versions.length > 0">
  back to home
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download