0

I have variable like below

$scope.priceOption = [];
$scope.priceOption['flip'] =            {
    dbvalue: "option:flip",
    caption:"反転図面の作成",          
    price:{TN:100,
           UR:200,
           HD:300}
};
$scope.priceOption['car'] =         {
    dbvalue: "option:car", 
    caption:"植栽・自動車・外構の追加", 
    price:{TN:100,
           UR:200,
           HD:300}
};
var price_type="HD";

How can I get price with dynamic price_type in HTML?

<label>{{priceOption['car'].price[price_type]}}円</label>

// expect value is 300円, if price_type = "HD";

3
  • What is price_type? Kindly describe the question. I think its partially written. Commented Jun 8, 2016 at 9:04
  • 1
    priceOption['handwritten'].price[price_type] should work... Commented Jun 8, 2016 at 9:07
  • Please check the variable, you will see price with 3 types {TN, UR, HD} Commented Jun 8, 2016 at 9:08

2 Answers 2

1

Change var price_type="HD"; to $scope.price_type="HD";. The view doesn't see the variable you pass to binding.

Sign up to request clarification or add additional context in comments.

Comments

0

You should use $scope.price_type="HD" instead of var price_type="HD" because you can not access javascript variable in view other than declared with $scope

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.