我有一个$ scope.uses的变量(我把它丢弃在下面)。从“ng-repeat =”(key,val)的内部使用“,我不知道访问重复中的属性。我正在创建一个标签页(每个标签一个) crop“),每个都有一系列费用表(一旦我知道如何访问属性,我将需要一个嵌套的ng-repeat)。
----更新:这是我的观点:
<div>
<fieldset>
<tabset>
<!-- REPEAT FOR EACH CROP SELECTED-->
<tab ng-repeat="(key, val) in uses" heading={{key|capitalize}}>
<table class="table table-striped rowed">
<tbody>
<tr>
<th class="text-left" style="width:20%;"> </th>
<th class="text-left" colspan="4">ACRE</th>
<th class="text-left" colspan="4">
{{key.acres|number:1}} ACRE TOTALS
</th>
</tr>
<tr>
<td style="width:10%;" class="text-right"> </td>
<td class="text-center" style="width:10%;">ARM</td>
<td class="text-center" style="width:10%;">
{{loan.distributor}}
</td>
<td class="text-center" style="width:10%;">Other</td>
<td class="text-center" style="width:10%;">Total</td>
<td class="text-center" style="width:10%;">ARM</td>
<td class="text-center" style="width:10%;">
{{loan.distributor}}
</td>
<td class="text-center" style="width:10%;">Other</td>
<td class="text-center" style="width:10%;">Total</td>
</tr>
<tr ng-if="uses.expenses.length == 0">
<td colspan="9">
<strong>No expenses recorded.</strong>
</td>
</tr>
<tr ng-repeat="c in x.expenses">
<td>
{{c.expense|capitalize}}
</td>
<td class="text-right" ng-class="gtZero(c.arm)">
{{c.arm|flexCurrency:2}}
</td>
<td class="text-right" ng-class="gtZero(c.dist)">
{{c.dist|flexCurrency:2}}
</td>
<td class="text-right" ng-class="gtZero(c.other)">
{{c.other|flexCurrency:2}}
</td>
<td class="text-right" ng-class="gtZero(c.peracre)">
{{c.peracre = c.arm * 1 + c.dist * 1 + c.other * 1|flexCurrency:2}}
</td>
<td class="text-right" ng-class="gtZero(c.calc_arm)">
{{c.calc_arm|flexCurrency:0}}
</td>
<td class="text-right" ng-class="gtZero(c.calc_dist)">
{{c.calc_dist|flexCurrency:0}}
</td>
<td class="text-right" ng-class="gtZero(c.calc_other)">
{{c.calc_other|flexCurrency:0}}
</td>
<td class="text-right" ng-class="gtZero(c.calc_total)">
{{c.calc_total|flexCurrency:0}}
</td>
</tr>
<tr class="success">
<td>TOTAL</td>
<td ng-class=gtZero(x.totals.acre_arm)>
{{x.totals.acre_arm | flexCurrency:2 }}
</td>
<td ng-class=gtZero(x.totals.acre_dist)>
{{x.totals.acre_dist | flexCurrency:2 }}
</td>
<td ng-class=gtZero(x.totals.acre_other)>
{{x.totals.acre_other | flexCurrency:2 }}
</td>
<td ng-class=gtZero(x.totals.acre_total)>
{{x.totals.acre_loan | flexCurrency:2 }}
</td>
<td ng-class=gtZero(x.totals.loan_arm)>
{{x.totals.arm | flexCurrency:0 }}
</td>
<td ng-class=gtZero(x.totals.loan_dist)>
{{x.totals.dist | flexCurrency:0 }}
</td>
<td ng-class=gtZero(x.totals.loan_other)>
{{x.totals.other | flexCurrency:0 }}
</td>
<td ng-class=gtZero(x.totals.loan_total)>
{{x.totals.loan | flexCurrency:0 }}
</td>
</tr>
</tbody>
</table>
</tab>
</tabset>
</fieldset>
<!--<pre>{{farmExpenses | json}}</pre>-->
<pre>{{uses | json}}</pre>
</div>
---- END UPDATE
{
"corn": [
{
"crop": "corn",
"acres": 347.4,
"expense": "Fertilizer",
"arm": 0,
"dist": 164.97,
"other": 0,
"peracre": 164.97,
"calc_arm": 0,
"calc_dist": 57310.578,
"calc_other": 0,
"calc_total": 57310.578
},
{
"crop": "corn",
"acres": 347.4,
"expense": "Seed",
"arm": 0,
"dist": 0,
"other": 115,
"peracre": 115,
"calc_arm": 0,
"calc_dist": 0,
"calc_other": 39951,
"calc_total": 39951
},
{
"crop": "corn",
"acres": 347.4,
"expense": "Fungicide",
"arm": 0,
"dist": 0,
"other": 0,
"peracre": 0,
"calc_arm": 0,
"calc_dist": 0,
"calc_other": 0,
"calc_total": 0
},
{
"crop": "corn",
"acres": 347.4,
"expense": "Herbicide",
"arm": 0,
"dist": 32.94,
"other": 0,
"peracre": 32.94,
"calc_arm": 0,
"calc_dist": 11443.356,
"calc_other": 0,
"calc_total": 11443.356
},
{
"crop": "corn",
"acres": 347.4,
"expense": "Insecticide",
"arm": 0,
"dist": 0,
"other": 0,
"peracre": 0,
"calc_arm": 0,
"calc_dist": 0,
"calc_other": 0,
"calc_total": 0
},
{
"crop": "corn",
"acres": 347.4,
"expense": "Custom",
"arm": 18,
"dist": 0,
"other": 0,
"peracre": 18,
"calc_arm": 6253.2,
"calc_dist": 0,
"calc_other": 0,
"calc_total": 6253.2
},
{
"crop": "corn",
"acres": 347.4,
"expense": "Fuel",
"arm": 40,
"dist": 0,
"other": 0,
"peracre": 40,
"calc_arm": 13896,
"calc_dist": 0,
"calc_other": 0,
"calc_total": 13896
},
{
"crop": "corn",
"acres": 347.4,
"expense": "Labor",
"arm": 20,
"dist": 0,
"other": 0,
"peracre": 20,
"calc_arm": 6948,
"calc_dist": 0,
"calc_other": 0,
"calc_total": 6948
},
{
"crop": "corn",
"acres": 347.4,
"expense": "Repairs",
"arm": 20,
"dist": 0,
"other": 0,
"peracre": 20,
"calc_arm": 6948,
"calc_dist": 0,
"calc_other": 0,
"calc_total": 6948
},
{
"crop": "corn",
"acres": 347.4,
"expense": "Insurance",
"arm": 0,
"dist": 0,
"other": 0,
"peracre": 0,
"calc_arm": 0,
"calc_dist": 0,
"calc_other": 0,
"calc_total": 0
},
{
"crop": "corn",
"acres": 347.4,
"expense": "Harvesting",
"arm": 0,
"dist": 0,
"other": 0,
"peracre": 0,
"calc_arm": 0,
"calc_dist": 0,
"calc_other": 0,
"calc_total": 0
},
{
"crop": "corn",
"acres": 347.4,
"expense": "Misc Acre",
"arm": 20,
"dist": 0,
"other": 0,
"peracre": 20,
"calc_arm": 6948,
"calc_dist": 0,
"calc_other": 0,
"calc_total": 6948
},
{
"crop": "corn",
"acres": 347.4,
"expense": "Living Expenses",
"arm": 60,
"dist": 0,
"other": 0,
"peracre": 60,
"calc_arm": 20844,
"calc_dist": 0,
"calc_other": 0,
"calc_total": 20844
}
],
"soybeans": [
{
"crop": "soybeans",
"acres": 580.3,
"expense": "Fertilizer",
"arm": 0,
"dist": 26.5,
"other": 0,
"peracre": 26.5,
"calc_arm": 0,
"calc_dist": 15377.95,
"calc_other": 0,
"calc_total": 15377.95
},
{
"crop": "soybeans",
"acres": 580.3,
"expense": "Seed",
"arm": 0,
"dist": 0,
"other": 60,
"peracre": 60,
"calc_arm": 0,
"calc_dist": 0,
"calc_other": 34818,
"calc_total": 34818
},
{
"crop": "soybeans",
"acres": 580.3,
"expense": "Fungicide",
"arm": 0,
"dist": 12.5,
"other": 0,
"peracre": 12.5,
"calc_arm": 0,
"calc_dist": 7253.75,
"calc_other": 0,
"calc_total": 7253.75
},
{
"crop": "soybeans",
"acres": 580.3,
"expense": "Herbicide",
"arm": 0,
"dist": 20.06,
"other": 0,
"peracre": 20.06,
"calc_arm": 0,
"calc_dist": 11640.818,
"calc_other": 0,
"calc_total": 11640.818
},
{
"crop": "soybeans",
"acres": 580.3,
"expense": "Insecticide",
"arm": 0,
"dist": 10.67,
"other": 0,
"peracre": 10.67,
"calc_arm": 0,
"calc_dist": 6191.801,
"calc_other": 0,
"calc_total": 6191.801
},
{
"crop": "soybeans",
"acres": 580.3,
"expense": "Custom",
"arm": 22,
"dist": 0,
"other": 0,
"peracre": 22,
"calc_arm": 12766.6,
"calc_dist": 0,
"calc_other": 0,
"calc_total": 12766.6
},
{
"crop": "soybeans",
"acres": 580.3,
"expense": "Fuel",
"arm": 30,
"dist": 0,
"other": 0,
"peracre": 30,
"calc_arm": 17409,
"calc_dist": 0,
"calc_other": 0,
"calc_total": 17409
},
{
"crop": "soybeans",
"acres": 580.3,
"expense": "Labor",
"arm": 20,
"dist": 0,
"other": 0,
"peracre": 20,
"calc_arm": 11606,
"calc_dist": 0,
"calc_other": 0,
"calc_total": 11606
},
{
"crop": "soybeans",
"acres": 580.3,
"expense": "Repairs",
"arm": 10,
"dist": 0,
"other": 0,
"peracre": 10,
"calc_arm": 5803,
"calc_dist": 0,
"calc_other": 0,
"calc_total": 5803
},
{
"crop": "soybeans",
"acres": 580.3,
"expense": "Insurance",
"arm": 0,
"dist": 0,
"other": 14.35,
"peracre": 14.35,
"calc_arm": 0,
"calc_dist": 0,
"calc_other": 8327.305,
"calc_total": 8327.305
},
{
"crop": "soybeans",
"acres": 580.3,
"expense": "Harvesting",
"arm": 0,
"dist": 0,
"other": 0,
"peracre": 0,
"calc_arm": 0,
"calc_dist": 0,
"calc_other": 0,
"calc_total": 0
},
{
"crop": "soybeans",
"acres": 580.3,
"expense": "Misc Acre",
"arm": 20,
"dist": 0,
"other": 0,
"peracre": 20,
"calc_arm": 11606,
"calc_dist": 0,
"calc_other": 0,
"calc_total": 11606
},
{
"crop": "soybeans",
"acres": 580.3,
"expense": "Living Expenses",
"arm": 43,
"dist": 0,
"other": 0,
"peracre": 43,
"calc_arm": 24952.9,
"calc_dist": 0,
"calc_other": 0,
"calc_total": 24952.9
}
]
}
答案 0 :(得分:0)
(key, val)
在转发器中用于需要值和名称的填充下拉列表。对于这种情况,您需要执行ng-repeat="item in corn"
,这样您就可以使用每个'玉米'的整套属性。
如果对象使用中有数组玉米,则ng-repeat="corn in uses.corn"
我认为当你说属性时你会引用属性。
属性是这样的:<corn crop="corn">
但是当你做{'corn':{ 'crop' : 'corn' }}
裁剪是对象的属性玉米