I have a pipe that is supposed to add the sub totals together to return the grand total but it just returns the sub total. It returns sub_total = product_price * quantity; and not the sum of the sub totals.
This is my pipe: @Pipe({ name: 'grandtotal' }) export class GrandTotalPipe implements PipeTransform { transform(product_price: number, quantity: number) { var totals = []; var sub_total; sub_total = product_price * quantity; totals.push(sub_total); var i; var grand_total = 0; for (i = 0; i < totals.length; i++) { grand_total += totals[i]; } return grand_total; } } This is how I call the pipe in the HTML: <div>Grand Total {{ product_price | grandtotal: quantity : sub_total : grand_total : totals }}</div> When I remove "var totals = [];", I get "cannot read property push of undefined." When I just use "var totals;", I get "Subsequent variable declarations must have the same type. Variable 'totals' must be of type 'any[]', but here has type 'any'." -- You received this message because you are subscribed to the Google Groups "Angular and AngularJS discussion" group. To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/angular/77b9b6ce-ffb0-49a5-af64-0ca6e802e934o%40googlegroups.com.