0

I don't understand how ng-if works:

I would like that a button in a list is visible only if a condition is verified. In the example below, a button should only be visible if a list element has title == 'Title2'

<ul>
    <li ng-repeat="o in options">{{o.title}}
        <button ng-if="o.title=='Title2'">BTN</button>
    </li>
</ul>

But as you can see from the code here all array elements show up

MHX
  • 1,581
  • 2
  • 21
  • 31
Gyonder
  • 3,674
  • 7
  • 32
  • 49
  • 1
    Note: replacing `ng-if` with `ng-show` works in your plnkr. I'm still investigating why this is. – Adam Zerner Aug 09 '15 at 17:39
  • 6
    You're using an ante-diluvian version of angular (in Internet time), which is full of bugs fixed since. Here's an up-do-date version, which works fine: http://plnkr.co/edit/5m9Rk9zcheklKzsjd6SK?p=preview – JB Nizet Aug 09 '15 at 17:40
  • For me your plunker worked as it is. Anyway I will sugest you use `===` for comparison just as good practices and because of type coercion – Raulucco Aug 10 '15 at 15:42

0 Answers0