我有以下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"
}
我的控制器:
var userLogged = 'SMITH00010';
$scope.updateValue = function(qtd) {
$scope.newHireRate = $scope.product.{{userLogged}}.hireRate * qtd;
}
我想根据用户的登录信息显示产品的合适价格。
这不是这样的,我确信有办法做到这一点,任何人都可以帮助我吗?
答案 0 :(得分:2)
您需要从
更新$scope.newHireRate = $scope.product.{{userLogged}}.hireRate * qtd;
到
$scope.newHireRate = $scope.product[userLogged].hireRate * qtd;