Access first element of ng-repeat
How can I access the first qty and price values in each subsequent row:
"selection" in this case is variable set by some radio buttons.
<tr ng-repeat="(qty, price) in product.sizes[selection]">
<td><input type="radio"> <% qty %></td>
<td><% price %></td>
<td>You save (actual calc more complex) {{price - FIRSTROWPRICE}}</td>
</tr>
I can prevent that last row from doing the math by using $first/ng-if so
no issues for that.
Here's the data:
{
"name": "The product",
"sizes": {
"2x2": { "100": "55", "200": "80", "300": "95"},
"3x3": { "100": "155", "200": "180", "300": "195"}
}
}
And the "selection" param is selected using some radio buttons:
<form>
<div class="radio" ng-repeat="(size, data) in product.sizes">
<label>
<input type="radio" value="{{ size }}" ng-model="$parent.selection">
{{ size }}
</label>
</div>
</form>
No comments:
Post a Comment