大家好我想将Buyer_name
的输入值提取到Copied Buyer_name
输入字段。我尝试了很多方法,但如果有人知道解决方案就无法找到解决方案请帮帮我.... { {3}}
控制器: -
$('#supname').change(function() {
$('#supnamecopy').val($(this).val());
});
HTML: -
<label for="quantity">Quantity</label>
<input type="text" ng-model="state.quantity" id="quantity" typeahead="state as state.quantity for state in states | filter: $viewValue">
<label for="quantity">Buyer_name</label>
<input type="text" id="supname" ng-model="state.quantity" typeahead="state.buyer_name for state in states | filter: $viewValue">
<label for="quantitycopy">Copied Buyer_name</label>
<input type="text" name="supnamecopy" id="supnamecopy" ng-model="copied">
我的数据:
$scope.states = [{
"_id": "5744009c2f0f2bef0ca707ef",
"user": {
"_id": "57400c32bd07906c1308e2cf",
"displayName": "mani selvam"
},
"description_count": "check",
"description_quality": "new",
"__v": 1,
"created": "2016-05-24T07:19:56.471Z",
"cone": "pending",
"status": "pending",
"currency": "Rs",
"unit": "KG",
"price": [
"500",
"400"
],
"actual_devlivery_date": "2016-05-2",
"ex_india_date": "2016-05-24",
"quantity_unit": "KG",
"quantity": "34",
"enquiry_received_date": "2016-05-24",
"supplier_name": "Mani selvam",
"buyer_name": "Rohit"
},
答案 0 :(得分:1)
http://plnkr.co/edit/VIZkyM08IKuSChL5vvOL?p=preview
HTML - 保持原样
JS - 将jQuery更改为角度功能。
目前设置ng模型的方式是将$ scope.state.quantity指定为选定状态而不是该状态的数量值。
$scope.$watch('state.quantity', function() {
if($scope.state && $scope.state.quantity && $scope.state.quantity.buyer_name) {
$scope.copied = angular.copy($scope.state.quantity.buyer_name);
} else {
$scope.copied = null;
}
});
答案 1 :(得分:0)
试试这个。这将为您提供该副本的实时预览
<label for="quantity">Buyer_name</label>
<input type="text" id="supname" ng-model="state.quantity" typeahead="state.buyer_name for state in states | filter: $viewValue">
<label for="quantitycopy">{{state.quantity}}</label>
<input type="text" name="supnamecopy" id="supnamecopy" ng-model="copied">