混合一次绑定和双向绑定与ngClass

时间:2015-10-29 13:38:35

标签: angularjs binding ng-class

是否可以在同一表达式中混合一次绑定和双向绑定?

到目前为止我已尝试过:

//Both will be one time binding
ng-class="::{test: testCond, test2: test2Cond}"

//Doens't work
ng-class="{::test: testCond, test2: test2Cond}"

//Can't have two of them
ng-class="::{test: testCond}" ng-class="{test2: test2Cond}"

//Doesn't work
ng-class="{{::testCond?'test':''}} {{::testCond2?'test2':''}}"

那么,这可能吗?

1 个答案:

答案 0 :(得分:1)

如上所述:

  

我使用了一种解决方法:

 //One time binding in ng-class directive | two-way binding in regular class       

 attr ng-class="::{test: testCond}" class="{{}}"