Sudarvizhi J

Sudarvizhi J

  • NA
  • 101
  • 23.9k

custom scope variable within ng-repeat using angularjs

Mar 16 2018 1:12 AM
We have to use custom scope varibale within ng-repeat using angularjs, but it will return last value to all
<div ng-repeat="pro in UserProduct">
{{discountvalue}}
</div>
<script>
$http.get('/api/Product/ListOnlyProductOrderFeatured/', { params: {} }).success(function (data) {
$scope.UserProduct = data;
for (var i = 0; i < $scope.UserProduct.length; i++) {
$scope.generalprice = $scope.UserProduct[i].ec_shop_product_price;
$scope.discountprice = $scope.UserProduct[i].ec_shop_product_discount;
$scope.discountvalue = $scope.generalprice - $scope.discountprice;
}
})
</script>
Please anyone explain how to do ASAP

Answers (4)