Trying to create an array using ng-model,
<div ng-repeat="n in [1, 2, 3]">
<input type="text" class="form-control" ng-model="headers[$index].key">
<input type="text" class="form-control" ng-model="headers[$index].value">
</div>
After using angular.toJson ($scope.headers)
, I received:
{
"headers": {
"0": {
"key": "xxx",
"value": "yyy"
}
}
}
However, my desired output was:
{
"headers": [
{
"key": "xxx",
"value": "yyy"
}
]
}
Is it possible to achieve this format?