convert 1 to active and 0 inactive within ng-repeat angular

Asked

Viewed 65 times

3

I have a value of flagAtivo that is 1 for active and 0 for inactive within a ng-repeat which I display in a table, but I need this value to be Active if 1 and inactive if 0

           <tbody ng-repeat="oper in operadorasCartoes" >
                <tr>
                  <td>{{oper.nome}}</td>                   
                   <td>{{oper.cnpj}}</td>
                   <td>{{oper.flagAtivo}}</td>                    
                </tr>               
              </tbody> 

You can do it by html ?

1 answer

3


One option is to use a ternary operator:

<tbody ng-repeat="oper in operadorasCartoes" >
  <tr>
    <td>{{oper.nome}}</td>
    <td>{{oper.cnpj}}</td>
    <td>{{oper.flagAtivo === 1 ? 'Ativo' : 'Inativo'}}</td>
  </tr>
</tbody>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.