angularjsng-classangularjs-ng-class

Ng-class not evaluating the given argument


I have a problem with the ng-class directive : i want to dynamically add a class when the screen size is large or medium. From what i can tell the condition is not being evaluated when generating the html or something like that because in the controller i see the correct value but the needed class is not added.

$scope.deviceLocal= $rootScope.devicee;
$rootScope.$on('size-changed', function(event, args) {
    $scope.deviceLocal = args.device;
});

and the html part

<label ng-class="{\'labelFloatRight\':deviceLocal == \'large\', \'labelFloatRight\':deviceLocal == \'medium\'}">

I escape the ' character because the label is inside a template formed with '.

Thanks, Vio


Solution

  • The Class name is same in both cases. Change the class name according to deviceLocal value.