How to populate pModel(50gm,100gm,250gm) in drop down using Angular JS
$scope.products=
{
"shopId" : "569df5c1d08598371e9b5ad5",
"mProId" : "569e07ccd08598371ebe5409",
"priceTag" : [
{
"pModel" : "50gm",
"priceTagId" : 1,
},
{
"pModel" : "100gm",
"priceTagId" : 2,
},
{
"pModel" : "250gm",
"priceTagId" : 3,
}
]
}
I am doing in this way.I dont know how it wont populate .Please help me to populate this one. This is my code
<select class="form-control" id="pricetags" ng-model="selectedPriceTag"
ng-options="product.priceTag.pModel for product in products" >
</select>
Here is a Plunker Demo
The problem is because you need to iterate through the priceTag
property in products.
I recommend you update your code to the following
<select class="form-control" id="pricetags" ng-model="selectedPriceTag"
ng-options="priceTag.pModel for priceTag in products.priceTag" >
</select>