Why does this work:
<span>${{10 + 20}}</span>
<!-- <span>$30</span> -->
But this doesn't work:
<span>${{cart.subtotal + cart.taxTotal}}</span>
<!-- <span>$1020</span> -->
It seems that the properties from the component are passed to the template as strings, irregardless that they are typed as numbers
on the component itself.
If you are using $
angular tries to parse it as a template expression. How ever you can use the currency pipe to display the currency on your template
<span>{{cart.subtotal + cart.taxTotal | currency:'USD':true}}</span>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.