JavaScript ng-if in ng-repeat angularjs angularjs repeat index,angularjs repeat filter,angularjs repeat n times,

I need to define different style by the value of a champ in ng-repeat, i try this :

<thead>
    <tr><th>#</th><th>Nom</th><th>Ville</th><th style="width: 50%;">Lignée</th></tr>
</thead>
<tbody>
    <tr ng-repeat="alternate1 in alternateViewText1.features | orderBy:'fiche.id*1'">
        <td>{{alternate1.fiche.id}}</td>
        <td ng-if="alternate1.properties.statut_activite == 'yes'" style="color: green;">{{alternate1.properties.nom}}</td>
        <td ng-if="alternate1.properties.statut_activite == 'no'" style="color: red;">{{alternate1.properties.nom}}</td>
        <td>{{alternate1.properties.ville}}</td>
        <td>{{alternate1.properties.lignee}}</td>
    </tr>
</tbody>

it's not working (nothing show)

how can i define automatically a style with a particular value ?

Answer:1

You use the wrong value in your test

jsFiddle

Replace yes by actif and no by inactif

Example :

<td ng-if="alternate1.properties.statut_activite == 'actif'" style="color: green;">{{alternate1.properties.nom}}</td>
<td ng-if="alternate1.properties.statut_activite == 'inactif'" style="color: red;">{{alternate1.properties.nom}}</td>

PS:

The answer of ssilas777 is the best way to execute this switch of css class

Answer:2

I am trying to make an animation of the effect of an opening door. Is there any known algortihms for doing this? If not, I need to alter a rectangular div making the right side longer than the left ...

I am trying to make an animation of the effect of an opening door. Is there any known algortihms for doing this? If not, I need to alter a rectangular div making the right side longer than the left ...

I'm trying to debug a Firefox extension, using Firefox 28.0. I have set up the dev environment as suggested in https://developer.mozilla.org/en-US/Add-ons/Setting_up_extension_development_environment ...

I'm trying to debug a Firefox extension, using Firefox 28.0. I have set up the dev environment as suggested in https://developer.mozilla.org/en-US/Add-ons/Setting_up_extension_development_environment ...

  1. debugging firefox extension
  2. javascript debugging extension firefox
  3. firefox extension debugging not working

In Google Chrome > right click HTML page > Inspect Element > Network tab Is there a way to filter the files you see in his tab when requests are made from the browser? I sometimes get flooded with ...

In Google Chrome > right click HTML page > Inspect Element > Network tab Is there a way to filter the files you see in his tab when requests are made from the browser? I sometimes get flooded with ...

I am a JS newbie with a complex problem. I want to find out the background color of any webpage. The problem is sometime it is defined in the body tag, sometimes in inline or external css and in a ...

I am a JS newbie with a complex problem. I want to find out the background color of any webpage. The problem is sometime it is defined in the body tag, sometimes in inline or external css and in a ...