Here I have two mongo collections. Contents from the first collection is listed using ng-repeat. While looping this three ng-repeats are provided since I am fetching key value pair. The first ng-repeat for looping the collection then the two for loopong the key value pairs of an object array inside each document. So in my second collection I want to insert this object array along with a new key value pair to each index. This is my first mongo collection, i have an object array like this
"highlight" : [
{
"status" : "upcoming"
},
{
"status" : "overdue"
},
{
"status" : "today"
}
]
and i have looped this in ng-repeat my html is like this
<div layout="row" ng-repeat="list in dynamicSettingsCtrl.features.settings">
<fieldset class="standard">
<md-checkbox aria-label="Checkbox 1" ng-model="moreOptions">
<p>{{list.name}}</p>
</md-checkbox>
<div layout-gt-sm="row">
<div ng-if="moreOptions">
<form name="dashboard">
<md-input-container class="md-block" flex-gt-sm>
<label>Set Limt</label>
<input ng-model="dynamicSettingsCtrl.setValues.maxLimit" ng-pattern="/^(\d)+$/" />
<p class="alert" ng-show="dashboard.maxLimit.$error.pattern">Numbers only, please.</p>
</md-input-container>
<div ng-repeat="highlight in list.highlight">
<span ng-repeat="(key, value) in highlight">Set the limit where <b>{{key}}</b> is <b>{{value}}</b></span>
<md-input-container class="md-block" flex-gt-sm>
<label></label>
<input ng-model="dynamicSettingsCtrl.setValues.upLimit[$index]
" ng-pattern="/^(\d)+$/" />
</md-input-container>
</div>
<md-button class="md-raised md-primary" ng-click="dynamicSettingsCtrl.addCount()">Submit</md-button>
</form>
</div>
</div>
</fieldset>
</div>
after entering values the expected new mongo collection should look like this.
Now i want to store limit for each of this status like
"highlight" : [
{
"status" : "upcoming",
"limit":"10"
},
{
"status" : "overdue",
"limit":"1"`
},
{
"status" : "today",
"limit":"3"
}
]
I want to set limit for each status. that is I want to set limit of status=overdue to 1 and so on. since the ng-model has same name for all the key value pair when i try adding limit every field changes to same. So i tried using index,then it was OK! but i know that using index is not a proper method. Somebody suggest me how to work with ng-init on this, or any other possible method. How can i get the correct values to my controller. How to insert the values to my second collection? Thanks in advance