How to add object in array and show it on web-page?
http://plnkr.co/edit/19w1Q3XhoWQcpxm5SuxX?p=preview
$scope.add = function() {
$scope.items.push($scope.item);
$scope.item = '';
};
We started with Q&A. Technical documentation is next, and we need your help.
Whether you're a beginner or an experienced developer, you can contribute.
How to add object in array and show it on web-page? http://plnkr.co/edit/19w1Q3XhoWQcpxm5SuxX?p=preview
}; |
|||
Hi just edit your function because its an object , u have to create object and need to push inside an array
|
|||
|
Just change your push code to:
You are trying to push single string to an Array of objects. you can also change your model in controller to
and on your view change ng-model to
|
||||
|
$scope.items.push({'item':$scope.item});
so the item object will have the same structure of data than the others. – Walfrat Jun 27 at 9:28