AngularJS-具有ng-repeat值的ng-class [英] AngularJS - ng-class with value from ng-repeat

查看:65
本文介绍了AngularJS-具有ng-repeat值的ng-class的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试使用ng-repeat值的ng-class设置tr的类.我在网上看到的所有示例似乎都调用了一个函数.我可以只给ng-class设置一个值而不是使用一个函数吗?

I'm trying to set the class of a tr using ng-class with the value of ng-repeat. All the examples I see online seem to call a function. Can i just set the ng-class with a value rather than using a function?

这些工作都没有.

<tr ng-class="{{res.resopnse.label}}" ng-repeat="res in responses">
<tr ng-class="res.resopnse.label" ng-repeat="res in responses">
<tr ng-class="{res.resopnse.label}" ng-repeat="res in responses">

推荐答案

如果没有条件逻辑,则可以直接插值到 class 属性:

If you have no conditional logic, you can just interpolate into class attribute directly:

<tr class="{{res.resopnse.label}}" ng-repeat="res in responses">

这篇关于AngularJS-具有ng-repeat值的ng-class的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆