Reputation: 3307
I have data being passed to my view in following format
id name color type 1 Ford red sdean 2. Nisan blue truck ........
Following dropdown populates it by name
<tr ng-repeat="p in allautos">
<td>
<select ng-model="p.id" ng-options="c.id as c.name for c in records"></select>
</td>
<td>
<input type="text" ng-model=p.color />
</td>
<td>
<input type="text" ng-model=p.type />
</td>
</tr>
What I am trying to do is when name is selected in the drop down I want corresponding values to populate in the input fields of color and type. Please let me know the best way to achieve that. Thanks
Upvotes: 2
Views: 3066
Reputation: 9497
I think you are looking for this:
<select ng-model="p" ng-options="c.name for c in records track by c.id"></select>
http://plnkr.co/edit/m9ubFrYdAgPXMGhfri79?p=preview
This uses a tracking expression to help angular to match the auto in the option array.
Upvotes: 3