javascript - Angular ng-repeat math -


i want create math inside angular expression, following; user can have credit site or user gets percentage in discount. have following code:

<div ng-repeat="item in newarrivals"> <div>{{item.newprice - usercredit | number:2}}</div> <div> 

what want when user logged in usercredit becomes number, simple, or if user not logged in usercredit -5% of item.newprice, , there problem.

this have in 'pagecontroller.js'

    if (theuser == "notthere") {         console.log('5% discount user')         var userdiscount = 0.95;     } else {         var usercredit = 300;     } 

how able newprice minus 5% each item in ng-repeat if user logged in? without making 2 different ng-repeats.

this how can manage it

<div ng-repeat="item in newarrivals">   <div ng-if="userdiscount">{{item.newprice * userdiscount | number:2}}</div>   <div ng-if="usercredit">{{item.newprice - usercredit | number:2}}</div> <div> 

Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -