0

I have a table with results:

<tr ng-repeat="result in results">
    <td>{{result.foo}}</td>
    <td ng-if="result.bar == '1'">it's One!</td>
    <td ng-if="result.bar != '1'">it's not One! is {{result.bar}}</td>
</tr>

the 3 are displayed, why the ng-if is not working?

the results are correctly setted in the scope because the "it's not One! is 5 is displayed OK"

4
  • 2
    could you show controller code or results data structure Commented Feb 12, 2014 at 20:37
  • <td ng-if="5 == 6">foo</td> it's displayed, why? Commented Feb 12, 2014 at 20:45
  • i've solved my problem, its the angular version, with 1.2.12 ng-if works, but with the 1.0.1 not. test with this example: Click me: <input type="checkbox" ng-model="checked" ng-init="checked=true" /><br/> Show when checked: <span ng-if="checked" class="animate-if"> I'm removed when the checkbox is unchecked. </span> Commented Feb 12, 2014 at 20:51
  • ye i was just going to point you out on that Commented Feb 12, 2014 at 20:51

2 Answers 2

1

it's a version problem.

html example:

Click me: <input type="checkbox" ng-model="checked" ng-init="checked=true" /><br/>
Show when checked:
<span ng-if="checked" class="animate-if">
  I'm removed when the checkbox is unchecked.
</span>

works with:

<script src="http://code.angularjs.org/1.2.12/angular.min.js"></script>

but not with:

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.1/angular.min.js"></script>
Sign up to request clarification or add additional context in comments.

Comments

0

Not sure why it doesn't work, but you could try an alternative way of doing it:

<tr ng-repeat="result in results">
  <td>{{result.foo}}</td>
  <ng-switch on="result.bar">
       <td ng-switch-when="1">it's One!</td>
       <td ng-switch-when="2">it's not One! is {{result.bar}}</td>
  </ng-switch>
</tr>

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.