当用户从rate
中选择时,我需要更新master_items
文本框。怎么可能,
HTML,
<tr ng-repeat="item in quotation.items track by $index">
<td>
<select ng-model="item.item" ng-options="master_item.name as master_item.name for master_item in master_items" class="form-control" ng-change="updateItem(master_item.rate,$index)"></select>
</td>
<td><input type="text" step="any" min="0" max="99999999" class="form-control" ng-model="item.quantity" placeholder="Quantity" required/></td>
<td><input type="text" step="any" min="0" max="99999999" class="form-control" ng-model="item.rate" placeholder="Rate" required /></td>
<td><input type="text" step="any" class="form-control" placeholder="Amount" value="{{item.quantity * item.rate}}" disabled/></td>
<th><a href="javascript:void(0)" ng-if="$index > 0" ng-click="removeInputElement($index)"><i class="fa fa-remove red"></i></a></th>
</tr>
在这里,当用户从主项目中选择一个选项时,我想更新相应的费率字段。这里选择框工作正常,每个选项都有正确的值,但我不知道如何获得选择的选项值。
我的master_items
JSON
是,
{
"total": 5,
"per_page": 100,
"current_page": 1,
"last_page": 1,
"next_page_url": null,
"prev_page_url": null,
"from": 1,
"to": 5,
"data": [
{
"id": 63,
"name": "Lumia 6252",
"description": null,
"unit": null,
"rate": "12.00",
"created_by": 0,
"updated_by": null,
"delete_by": null,
"created_at": "2015-03-15 17:38:40",
"updated_at": "2015-03-15 17:38:40",
"deleted_at": null,
"status": 1
}
}
。
答案 0 :(得分:0)
试试此代码
<select ng-model="item.item" ng-options="master_item.name as master_item.name for master_item in master_items" class="form-control" ng-change="updateItem(this,$index)"></select>
$scope.updateItem=function(data,index)
{
var abjValue= data.item.item.name// You can see with quick watch for what value return from this name
}