NVO NVO - 2 months ago 10
AngularJS Question

Angular ng-repeat in table, adding extra rows

I'm repeating the contents of a array using ng-repeat with Angular. After that, but in the same table, I want to add some extra rows with info. But because it is in the ng-repeat I get an angular error on {{getCartTotal()}}, which is now called infinite times.

Is there a way to stop the ng-repeat, or a other way to add extra rows after a ng-repeat in the same element?

This is the code I have (in Jade). Only the first tr must been repeating.

table.shop_table.woocommerce-checkout-review-order-table
tbody
tr(ng-repeat='product in shoppingCart')
th
{{product.name}}
span.count x {{product.quantity}}
td
span.amount € {{product.price * product.quantity | number:2}}
tr.cart-subtotal(ng-repeat-end)
th Subtotaal
td
span.amount € {{getCartTotal()}}}
tr.shipping
th Verzendkosten
td
span
i
| Tijdelijk gratis!
tr.order-total
th
strong Totaal
td
strong
span.amount € {{getCartTotal())}}

Answer

Duplicate from comment.

ng-repeat-end used with ng-repeat-start and will be repeated too. Try to delete ng-repeat-end

tr(ng-repeat='product in shoppingCart')
    th 
        {{product.name}}
        span.count  x {{product.quantity}}
        td
          span.amount € {{product.price * product.quantity | number:2}}
tr.cart-subtotal
    th Subtotaal
        td
            span.amount € {{getCartTotal()}}