【问题标题】:Mix one time binding and two-way binding with ngClass使用 ngClass 混合一次绑定和双向绑定
【发布时间】:2016-01-29 16:31:25
【问题描述】:

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

到目前为止我已经尝试过:

//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':''}}"

那么,这可能吗?

【问题讨论】:

  • 您能解决这个问题或找到解决方法吗?我自己也很好奇。
  • @NoahB 不,我使用了一种解决方法! //ng-class 指令中的一次绑定 |常规类中的双向绑定 attr ng-class="::{test: testCond}" class="{{}}"
  • ng-class one time binding的可能重复

标签: angularjs binding ng-class


【解决方案1】:

如上所述:

我使用了一种解决方法:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-16
    • 2023-03-14
    • 1970-01-01
    • 1970-01-01
    • 2014-12-24
    相关资源
    最近更新 更多