Search code examples
htmlarraysangularjsangular-ng-if

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?


Solution

  • It should be:

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

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