Search code examples
angularjsng-class

Applying classes conditionally - Not working


I want to add a class to an element when a property is true:

<div class="row-wrap" ng-class="{row-wrap-animation: Resizing == false}">

The row-wrap-animation class is not applied correctly. I set the property $scope.Resizing = false right at the start and the class is not there.

Is there something wrong with the above syntax?

app.controller( 'PageLayoutController', function ( $scope )
{
    $scope.Resizing = false;
    ...

Solution

  • <div class="row-wrap" ng-class="Resizing ? '' : 'row-wrap-animation'"></div>
    
    ng-class="Resizing ? 'anything' : 'row-wrap-animation'"
    //        property     if true         if false