I have a template. In the template, there are three boxes. Each box has add button, which will add an input field in that box. I have tried the following codes.
HTML
<div class="row">
<div ng-repeat="item in items2">
<div class="theBox">
<button class="btn btn-success" ng-click="addItem()">add</button>
<h6>{{item.key}}</h6>
<input ng-model="item.value">
</div>
</div>
</div>
AngularJs
$scope.items2 = [
{
"key" : "a",
"value" : []
},
{
"key" : "b",
"value" : []
},
{
"key" : "c",
"value" : []
}
];
$scope.addItem = function(){
console.log("clicked ")
angular.forEach($scope.items2, function(mm){
mm.value.push({})
})
}
The Problem: If I click on add, it's creating an object inside each value, maybe because I have used the forEach-loop for each value. How can I add it individually?
Also The input tag is not added as well, how can I fix that ?