1

I have have this select field:

enter image description here

code:

<select ng-model="productForm.productDesc.idproductDesc" ng-options="opt2.idproductDesc as opt2.description for opt2 in productDesc"/>

where productDesc is a result JSON text from a query, where productDesc is the table and idproductDesc and description are two attribute of this table. I want to show another attribute of productDesc, such as prize (opt2.price in this case). I want something like that:

enter image description here

however: opt2.name - opt2.price, for example if opt2.name is "Patatine fritte classiche" and opt2.price is 1: "Patatine fritte classiche - 1" (like in the second picture). Otherwise an output field with the opt2.price of the selected element, in this way:

enter image description here

how can I do it?

Mosh Feu
  • 28,354
  • 16
  • 88
  • 135
Giacomo Brunetta
  • 1,409
  • 3
  • 18
  • 38

1 Answers1

1

Solved in this way:

<select ng-model="productForm.productDesc.idproductDesc">
  <option ng-selected="{{productDesc.idproductDesc == productForm.productDesc.idproductDesc}}" ng-repeat="productDesc in productDescs" value="{{productDesc.idproductDesc}}">
    {{productDesc.price}} - {{productDesc.description}}
  </option>
</select>
Mosh Feu
  • 28,354
  • 16
  • 88
  • 135
Giacomo Brunetta
  • 1,409
  • 3
  • 18
  • 38