sacan
sacan

Reputation: 47

ng-if with multiple conditions wont work

<tbody ng-repeat= "course in year.courses">
     <tr ng-repeat="theCourse in vm.courses" ng-if="theCourse._id==course && theCourse.term==('VT2'||'VT1')">
          <td >{{theCourse.courseName}}</td>
          <td >{{theCourse.courseCode}}</td>
          <td >{{theCourse.term}}</td>
          <td >{{theCourse.block}}</td>
          <td >{{theCourse.credits}}</td>

       </tr>
</tbody>

The OR-condition wont work, I have tried doing like the above, but also tried like this:

<tr ng-if="theCourse._id==course && theCourse.term=='VT2'||theCourse.term=='VT1'">

Somebody know what I'm doing wrong?

Upvotes: 0

Views: 2527

Answers (2)

miqe
miqe

Reputation: 3369

may be use brackets

<tr ng-if="(theCourse._id==course && theCourse.term=='VT2')||theCourse.term=='VT1'">

i copied my comment, just to make it as an answer

Upvotes: 0

Huy Chau
Huy Chau

Reputation: 2240

It should be:

<tr ng-if="theCourse._id === course && (theCourse.term === 'VT2'|| theCourse.term === 'VT1')">

Note: You should use === to compare values.

Upvotes: 2

Related Questions