AngularJS ng-class multiple expression chain

I am trying to relate two different expressions to ng-class, one of them has a filter to it, something like:

<body ng-class="controller | camel2hyphens" ng-class="{overflow: isOverflow}">

But Angular uses only one of them (which makes sense).

I tried using an expression array like this:

<body ng-class="[(controller | camel2hyphens), {overflow: isOverflow}]">

But the CSS class installed:

class="login-controller [object Object]"

Is there a way to do this with ng-class(without writing a method in a controller with logic).

Thanks!

+4
source share
2 answers

You can use classin conjunction withng-class

<body class="{{controller | camel2hyphens}}" ng-class="{overflow: isOverflow}">
+3
source

It looks like how you tried to do this, only Angular> = 1.4 is supported .

Angular 1.2 1.3

, , .

, , ng-.

ng-class="[(controller | camel2hyphens), isOverflow ? 'overflow' : '']
+3

All Articles