2016-06-28 8 views
2

こんにちは、私はCopied Buyer_name入力field.iにBuyer_nameからの入力値を取得したいすべての多くの方法を試みたが、誰もが解決策を知っていれば解決策を見つけることができない私を助けてください.... my plunkある入力から別の入力に値をフェッチする方法は?

コントローラ: -

$('#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" 
}, 

答えて

1

http://plnkr.co/edit/VIZkyM08IKuSChL5vvOL?p=preview

HTMLコピーのライブプレビューをしなければならない - 角度の機能にjQueryのを変更 -

JSがあるとして残ります。

現時点であなたの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; 
    } 
}); 
+0

ありがとうございました! .......実際に私は数量を先にタイプしていましたが、もし私が数量値を選択すると、バイヤー名はフェッチしなければならず、コピーされたバイヤー名の値も必要です..... [私の塊り](plnkr.co/edit/yZ8h2G1BDolfwrkGkP4F ?p = preview)同じように私を助けてください.....例えば:もし私が数量34を選択すると、buyer_nameは自動的にフェッチされます。私はちょうどbuyer_nameの入力がコピーされたbuyer_nameまた.... –

+0

私はあなたのニーズを満たすために上記の答えを更新しました –

+0

私は簡単に(助けて理解している)プランナーを提供できればこんにちはRian .. !!!! –

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"> 
関連する問題