Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 如何使用引导类和angularjs为表中的数据添加背景色?_Html_Angularjs_Angular Ui Bootstrap - Fatal编程技术网

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}


谢谢。很简单,谢谢。这很简单。