I have angular app that user dynamic form field adding
HTML
<div class="sub_skus">
<div class="select-style">
<select data-ng-options="unitP as unitP.name for unitP in unitProducts" data-ng-model="choice.subProduct[choice.id]" data-ng-change="getUnitProductData(choice.id)">
</select>
</div>
</div>
<div class="sub_skus">
<input type="text" data-ng-model="choice.subSku">
</div>
<div class="sub_skus">
<input type="text" data-ng-model="choice.price" placeholder="Price">
</div>
<div class="sub_skus">
<input type="number" data-ng-model="choice.quantity" placeholder="Quantity">
</div>
<div>
<span ng-show="$last" ng-click="removeChoice()" class="input-group-addon a1 vd_bg-red vd_white rmMainIcon">
<i class="fa fa-minus"></i>
</span>
</div>
</div>
JS
$scope.unitProducts = {};
productService.getUnitProducts().then(function success(responce) {
$scope.unitProducts = responce.data.units;
console.log($scope.unitProducts);
});
$scope.choices = [{
id: '1'
}];
$scope.addNewChoice = function() {
var newItemNo = $scope.choices.length + 1;
$scope.choices.push({
'id': newItemNo
});
};
$scope.removeChoice = function() {
var lastItem = $scope.choices.length - 1;
$scope.choices.splice(lastItem);
};
when I select one option from select it will get below data from the service
[{"id":"1","subProduct":{"1":{"id":"15","name":"rrrr","sku":"rf","price":"3.00"}}}]
I want to set that above data to sku to choice.subSku
and price to choice.price
inside the loop ?