我在我的应用程序中使用 MEAN 堆栈,并将 AngularJS 作为我的前端。如何更改 green color
至 tollerence
159.06
在表中作为手动。 My Plunker
查看我的 plunker 以供引用。
我们做的有,我们用过
ng-show
如果值为greaterthan
,则在提交的 tollerrence 中>
到 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"
},]
- 我已经创建了我的 plunker 以供引用:- My Plunker
最佳答案
首先,我建议您使用 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>
关于html - 在 Angularjs 中手动批准时如何更改归档颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39444342/