Search code examples
javascriptangularjsng-class

Using a logical operator in an ngClass condition with Angular


I want to apply some styles when a batch status is not in progress or not done.

I wrote:

<td ng-class="{'paddingLeft' : item.status !== 'in progress' || item.status !== 'done'}">

This did not work.

But when I do them individually:

<td ng-class="{'paddingLeft' : item.status !== 'in progress'}">

or

<td ng-class="{'paddingLeft' : item.status !== 'done'}">

That works.

What am I doing wrong?


Solution

  • item.status !== 'in progress' || item.status !== 'done' this condition is always true.

    I think it should be:

    item.status !== 'in progress' && item.status !== 'done'