我無法將一個字段的值複製到下一個字段中。我在po num
中使用了typeahead。如果我同時選擇po num
的值,則自動填充quantity
值,並且需要從quantity
複製copied quantity
的值。
這是鏈接... my plunk ...請幫我解決這個問題。
例如: - 如果我從下拉列表中選擇po num
作爲1356
,則自動提取quantity
值爲100
。我希望copied quantity
的值與100
相同。AngularJS - 我怎樣才能從一個輸入字段獲取值到另一個字段使用angular.copy?
我已添加我在下面使用的代碼。請確認一下,讓我知道我犯了什麼錯誤。我知道它也可能是一個非常小的東西,請幫忙。在此先感謝
控制器: -
$scope.$watch('states.purchase_order_details_ord_no', function() {
if($scope.state && $scope.states.purchase_order_details_ord_no && $scope.states.purchase_order_details_ord_no.getTotalsshadeqty) {
$scope.copied = angular.copy($scope.states.purchase_order_details_ord_no.getTotalsshadeqty);
} else {
$scope.copied = null;
}
});
HTML: -
<div ng-repeat="states in states.pocomments">
<label for="purchase_order_details_ord_no">po num</label>
<input type="text" ng-model="states.purchase_order_details_ord_no" id="purchase_order_details_ord_no" typeahead="type as type.purchase_order_no for type in types | filter: $viewValue">
<label for="quantity">quantity</label>
<input type="text" id="supname" ng-model="states.purchase_order_details_ord_no" typeahead="type.getTotalsshadeqty for type in types | filter: $viewValue">
<label for="quantitycopy">Copied quantity</label>
<input type="text" name="supnamecopy" id="supnamecopy" ng-model="copied">
</div>
我的數據: -
$scope.types = [
{
"_id": "5768e6c8bdbc5db509f0f2b2",
"created": "2016-06-21T07:03:36.504Z",
"getTotalsshadeqty": "100",
"getTotalsprice": "1000",
"getTotalsqtyprice": "100000",
"purchase_order_no": "1356",
},
{
"_id": "5767cd78f5012d790aa41a7b",
"created": "2016-06-20T11:03:20.382Z",
"getTotalsshadeqty": "12",
"getTotalsprice": "10",
"getTotalsqtyprice": "120",
"purchase_order_no": "0987",
}];
$scope.states = {
"_id": "575691b26a5ec735128fe635",
"pocomments": [
{
"_id": "575691d56a5ec735128fe636",
"po_value_currency": "Rs",
"value": "124",
"rate": "24",
"quantity": "",
"purchase_order_details_ord_no": ""
},
]
這是一個表單數據的一部分,如果我使用$父,數據沒有得到保存..我用MEANJS –