Join the Stack Overflow Community
Stack Overflow is a community of 6.8 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

I have define blank array $scope.order, ON form submit data get and create new array then merge with existing array.

.controller('GuestDetailsCtrl',function($scope){
    $scope.order = [];
    $scope.itemDetails = function() {
        // Here data get after form submiti have array arrieve from form submit.
        $scope.order=$scope.order.push({name:$scope.item.name,price:$scope.item.price});
    }
});

I want result like this.

$scope.order = [{name:'abc',price:100},{name:'pqr',price:80},{name:'xyz',price:50}];

When itemDetails() call at that time array merge with new data.

share|improve this question
up vote 2 down vote accepted

push operates on the array in-place. Simply

$scope.order = [];
$scope.itemDetails = function() {
    // Here data get after form submiti have array arrieve from form submit.
    $scope.order.push({name:$scope.item.name,price:$scope.item.price});
}

(without assigning it), and that should work!

share|improve this answer
    
Ya.. this work's... Thanks dear... – Uttam Panara Jun 4 '15 at 5:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.