I am newbie to Angular JS. I did find for the solution, but didn't resolved it.
As per selected value in dropdown, value should be displayed in corresponding Input box.
For Eg: If Basic is selected, corresponding value i.e 299 should be displayed in ng-model item.rate If Advanced is selected, Corresponding value i.e. 499 should be displayed in ng-model item.rate.
HTML:
<tbody>
<tr ng-repeat="item in invoice.items ">
<td><select ng-model="item.names" ng-options="c.name for c in invoice.items track by c.id"></select></td>
<td><input type="text" ng-model="item.rate"/></td>
</tr>
</tr>
</tbody>
Angular JS:
$scope.invoice = {
items: [{id:1,name:'Basic',rate:299},
{id:2,name:'Advanced',rate:499}
]};
My Code is not working.I am unable to find out the Problem.Please help me.Thanks in advance.
you can use
ngOptions
full syntaxvalue as text for item in items
to bind the options withitem.rate
, see documentation.Also I recommend you to avoid binding
item.name
toselect
and binding an extra filed to avoid conflicts.refer below example.