I am trying to use the repeated variable from an ng-repeat in as part of the ng-model, which is passed to the controller to be inserted into MongoDB.
In the html below, I have used
<input... ng-model="tablesList.person.lastName />
where I really want an input for each column field
<input... ng-model="tablesList.person.{{column.field}} />
however, this produces an error. Neither does
<input... ng-model="tablesList.person.column.field />
which takes column.field as a string.
Any ideas how to get this to work? I have tried to use getter/setter function, but am not sure how to do this properly, or if this is necessary.
HMTL:
<form name="newTableRowForm" novalidate ng-cloak>
<td ng-repeat="column in tablesList.ammiTables">
<md-input-container flex class="md-block">
<input type="text" ng-model="tablesList.person.lastName" />
</md-input-container>
</td>
<td>
<md-button ng-click="tablesList.submit()" class="md-primary" ng-disabled="newTableRowForm.$invalid" aria-label="send">
Submit <md-icon md-svg-icon="content:ic_send_24px"></md-icon>
</md-button>
</td>
</tr>
</form>
Submit part of controller:
submit() {
this.person.owner = Meteor.user()._id;
Persons.insert(this.person);
if(this.done) {
this.done();
}
this.reset();
}