I have multiple select box on a page with each select box have a span listing its price. On select box change the price update dynamically based on the item. How I can achieve this using angularjs ?
My Code below
<div ng-repeat="items in itemsList" class="col-md-3 col-sm-3 ">
<div class="product product-category">
<div class="details">
<img src="resources/images/itemImages/{{items.image}}" style="width:159;height:159;" class="image" />
<h4 class="name">{{items.name}}<span class="quality">(Quality)</span></h4>
<h4 class="info">{{items.description}}</h4>
<select id="unit{{items.id}}" ng-init="itemUnitsSelected = items.itemUnitPrices[0]" ng-model="itemUnitsSelected" ng-change="changedValue(itemUnitsSelected, '{{items.id}}')" data-ng-options="XYZ as XYZ.unit.name for XYZ in items.itemUnitPrices track by XYZ.id " class="form-control item-count">
</select>
</div>
<div class="cart-feature">
<h5 class="price">
<span class="rate original"></span>
<span class="rate discounted" price="{{items.itemUnitPrices[0].itemPrice}}" id="discountedAmount{{items.id}}">Rs. {{items.itemUnitPrices[0].itemPrice}}</span>
</h5>
<div class="cart-option">
<span class="tag">Qty </span>
<span class="quantity">
<input type="text" value="1" id="qty{{items.id}}" class="form-control" />
</span>
<a href="javascript:return;" class="event" ng-click="addItemToCart(items.id,items.name)">
<span class="cart-btn"></span>
</a>
</div>
</div>
</div>
</div>
On my controller currently I am updating value through javascript, I want to change and bind it using angularjs.
$scope.changedValue=function(item,itemId){
document.getElementById("discountedAmount"+itemId).innerHTML = "Rs. "+item.itemPrice;
document.getElementById("discountedAmount"+itemId).setAttribute("price", item.itemPrice);
};