我在AngularJS作为前端的应用程序中使用MEAN stack。如何手动将表中的green color
修改为tollerence
159.06
?我恰好
-
看我的活塞参考
-
我们所做的是,我们在容差文件中使用
ng-show
,如果值是greaterthan
>
到100,它应该需要突出显示red color
。 -
如果值是
lesserthan
<
到100意味着它应该需要突出显示green color
-
如果
tollerence
值是greaterthan
>
100意味着它像red color
一样突出显示,所以一旦它被批准意味着这个值需要更改有green color
,那么我们将如何做更改作为一个手册,
Html: -
<td > <p ng-show="{{(mani.invoice_quantity *1) + (mani.conversion_rate *1) | number:2}}>100" style="background-color: red;">{{(mani.invoice_quantity *1) + (mani.conversion_rate *1) | number:2}}</p>
<p ng-show="{{(mani.invoice_quantity *1) + (mani.conversion_rate *1) | number:2}}<100" style="background-color: Green;">{{(mani.invoice_quantity *1) + (mani.conversion_rate *1) | number:2}}</p></td>
我的数据:-
$scope.sryarndebitnote = [
{
"_id": "57ac1b6d82e1c5940ac3c730",
"user": {
"_id": "57400c32bd07906c1308e2cf",
"displayName": "mani selvam"
},
"__v": 0,
"created": "2016-08-11T06:30:05.118Z",
"shipment_id": "57ac19b982e1c5940ac3c72f",
"conversion_rate": "62.04",
"invoice_value_fob_currency": "Rs",
"invoice_value_fob": "300.231",
"invoice_quantity_unit": "KG",
"invoice_quantity": "37",
"invoice_date": "2016-08-17",
"supplier_name": "Msd",
"buyer_name": "Mani selvam .R"
},
{
"_id": "57b5af69df0475401f644b2e",
"user": {
"_id": "57400c32bd07906c1308e2cf",
"displayName": "mani selvam"
},
"__v": 0,
"created": "2016-08-18T12:51:53.671Z",
"shipment_id": "57b5af5bdf0475401f644b2d",
"conversion_rate": "62.06",
"exclusive": true,
"invoice_value_fob": "400.343",
"invoice_quantity": "97",
"supplier_name": "Msd",
"buyer_name": "Mani selvam .R"
},]
- 我已经创建了我的活塞参考:-我的活塞
首先我建议你使用ngStyle
而不是这个ngShow
。如果你想手动更改它,你可以添加一个按钮,并添加一个更改
<td>
<p ng-style="{'background-color': (mani.invoice_quantity *1) + (mani.conversion_rate *1) > 100 || mani.approved ? 'green' : 'red'}">{{(mani.invoice_quantity *1) + (mani.conversion_rate *1) | number:2}}</p>
<button ng-click="mani.approved = true">Approve</button>
</td>