Search code examples
angularjsng-class

AngularJS Expressions in html tag


I am trying to use AngularJS Expressions in tag as below

class="({{product.id}} > 2) ? 'act':''"

after execution which can be this

class="( 5 > 2) ? 'act':' ' "

will it be possible that it cloud be like

class='act'

if yes then how ? I have tried above code but not getting

class='act'

same for ng-hide


Solution

  • This may help someone

    replace class to ng-class

    as below

    ng-class="{'act': product.id > 2}"

    replace ng-hide to ng-if

    as below

    ng-if="selectedItem == product.pageID"

    so you can skip records