Reputation: 1841
I have a situation where I return a dollar amount and a discount percentage from an API for a number of products. I have an ng-repeat, where nn the UI, I want to show a discounted amount.
Something like:
{{this.amount * .(100 - this.discount)}}
I tried this, but it doesn't work.
Any advice?
Upvotes: 1
Views: 2773
Reputation: 2259
Are both this.amount
and this.discount
defined? The use of this
here is strange, usually in angular you add variables you want to $scope
.
E.g.
In your controller: $scope.amount = 5
Then your view: {{amount}}
prints 5.
Ignoring this the use of the period before the brackets is causing your issue, try:
{{this.amount * (100 - this.discount) / 100}}
Upvotes: 3
Reputation: 443
remove this keyword. Instead, use scope variables to calculate the value.
{{amount * .(100 - discount)}}
Upvotes: 0
Reputation: 16587
This is the valid syntax: {{amount * 0.(100 - discount)}}
(notice that 0)
Upvotes: 0