Html 如何使用引导类和angularjs为表中的数据添加背景色?
我想做一个小的电子商务应用程序。在用户完成订单后,管理员获得了订单,订单项包括Html 如何使用引导类和angularjs为表中的数据添加背景色?,html,angularjs,angular-ui-bootstrap,Html,Angularjs,Angular Ui Bootstrap,我想做一个小的电子商务应用程序。在用户完成订单后,管理员获得了订单,订单项包括订单id,项目名称,价格,状态,btnclass 订单的默认状态为pending,btnclass的值为label warning,编辑订单pending后,将btnclass更改的值传递给label success。但我不知道怎么做 btnclass用于存储引导类 <table> <th>order id</th> <th>item name</t
订单id
,项目名称
,价格
,状态
,btnclass
订单的默认状态为pending,btnclass的值为label warning,编辑订单pending后,将btnclass更改的值传递给label success。但我不知道怎么做
btnclass
用于存储引导类
<table>
<th>order id</th>
<th>item name</th>
<th>price</th>
<th>status</th>
<th>total</th>
<tr ng-repeat="item in orders">
<td>{{item.orderid}}</td>
<td>{{item.itemname}}</td>
<td>{{item.price}}</td>
<td><p class="label {{list.btnclass}}">{{item.status}}</p></td>
<td>{{item.total}}</td>
</tr>
</table>
请帮助我如何为表数据提供类。实际上非常简单,您必须使用ng类 使用ng类,您可以传递一组类和条件,这些类和条件决定是否应用这些类,语法如下
<any ng-class="{'my-class':condition===true, 'my-second-class': someFunction()}" />
请注意,传递给ng类的参数是一个js对象,其中键是要应用的类的名称,值是条件,如果条件解析为true,则将应用用作键的类,否则将忽略它。如您所见,您可以使用第一种情况下的表达式(condition==true),也可以像我在第二个示例中所做的那样调用函数(someFunction()),尝试使用它来解决您的问题,并且,如果您不能随意请求进一步的帮助。实际上很简单,您必须使用ng类 使用ng类,您可以传递一组类和条件,这些类和条件决定是否应用这些类,语法如下
<any ng-class="{'my-class':condition===true, 'my-second-class': someFunction()}" />
请注意,传递给ng类的参数是一个js对象,其中键是要应用的类的名称,值是条件,如果条件解析为true,则将应用用作键的类,否则将忽略它。如您所见,您可以使用第一种情况下的表达式(condition==true),也可以像我在第二个示例中那样调用函数(someFunction()),尝试使用它来解决您的问题,如果您不能自由请求进一步的帮助。
ng class
对此很有用。您可以为状态创建两个CSS类,例如.delivered
或.pending
。并使用ng类指令:
<td><p ng-class="{'deliverd' : item.status === 'delivered', 'pending' === 'item.status === 'pending'}">{{item.status}}</p></td>
{{{item.status}
ng类
对此很有用。您可以为状态创建两个CSS类,例如.delivered
或.pending
。并使用ng类指令:
<td><p ng-class="{'deliverd' : item.status === 'delivered', 'pending' === 'item.status === 'pending'}">{{item.status}}</p></td>
{{{item.status}
谢谢。很简单,谢谢。这很简单。