Reputation: 11
I have the following json:
{
"id": "026001",
"description": "Drop Forged Double Coupler",
"CASHCUST01": {
"hireRate": "0.01500",
"saleRate": "2.50000"
},
"SMITH00010": {
"hireRate": "0.02500",
"saleRate": "1.50000"
},
"imageUrl": "images/fitting.jpg"
}
My controller:
var userLogged = 'SMITH00010';
$scope.updateValue = function(qtd) {
$scope.newHireRate = $scope.product.{{userLogged}}.hireRate * qtd;
}
I want to show the right price of the product based on what user is logged in.
It's not working this way, I'm sure there is a way to do it, anyone can help me?
Upvotes: 0
Views: 35
Reputation: 28445
You need to update from
$scope.newHireRate = $scope.product.{{userLogged}}.hireRate * qtd;
to
$scope.newHireRate = $scope.product[userLogged].hireRate * qtd;
Upvotes: 2