Venkatesh GS Rao Venkatesh GS Rao - 1 year ago 104
AngularJS Question

angular material select in ng-repeat

<tr ng-repeat="row in gridData">
<md-select placeholder="select AC" ng-model="row.bank_ac_no" md-on-open="loadUsers()">
<md-option ng-value="user" ng-repeat="user in users">{{user.bankacno}}</md-option>

<button ng-click="saveData(row)"></button>

This is my html, clearly, I am adding mdSelect within a loop, so I have to use the same ng-model for all of them in the loop, I want the "row.bank_ac_no" to store the name of md-select selected of the particular row. I am getting the whole json object in the ng-model instead of just the name in it. What should be done? Thanks in advance. :)

please refer to my pen here

Answer Source

Is this what you want? When I select a user, now I just get the name and not the whole json. Check my fork of your pen

All I had to do was set the ng-value to user.bankacno.

<md-option ng-value="user.bankacno" ng-repeat="user in users">
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download