I am working on angular project. I am facing error that last value of object shown in all array.
$scope.products = [{"product_id":"1", "price:80"},{"product_id":"2", "price:90"}]
Now i am using angular forEach method. actually I have much thing I product array so i use a order array where I I provide just id and value
angular.forEach($scope.products, function(value, key){
$scope.order.product_id = value.product_id;
$scope.order.price = value.price;
$scope.orderProducts.push($scope.order);
})
but I get
$scope.orders = [{"product_id":"2", "price:90"},{"product_id":"2", "price:90"}]
on my console I saw
objet{{"product_id":"1", "price:80"}
but when I open then I get
product_id:"2",
price: "90"