私は意味のある名前を持つテキストボックスを持っていて、それぞれに対応するテキストボックスを持っている単純なフォームを持っています。チェックボックスの値と対応するテキストボックスの値を取得する角度の方法
私はチェックボックスとそのIDのリストを提案に従うことで取得できますが、対応するテキストボックスの値を取得できません。
これを達成するためのガイダンスはありますか? FYIでは、チェックボックスの値はデータベースからのものであり、ng-repeatによって反復されます。ここで
は、コードスニペットは、私が正しくあなたを理解していれば、あなたは
$scope.materialList.push({
'materialId' : parseInt(materialId, 10),
'requiredQty' : $scope.itemList.find(x => x.inventoryId == materialId).requiredQty
});
またはこの...これを試みることができるいずれか
<tr ng-repeat="item in itemList | filter:search_query">
<td>
<label for="{{item.inventoryId}}">
<input type="checkbox" class="checkbox-circle"
ng-click="materialSelected(materialSelection.ids, item.inventoryId);"
ng-model="materialSelection.ids[item.inventoryId]" name="group" id="
{{item.inventoryId}}" /> {{item.itemName}}
</label>
</td>
<td><span>
<label>
<input type="text" class="form-control" ng-model="item.requiredQty">
</label></span>
</td>
Javascriptコード
$scope.materialSelected = function(idsList, inventoryId) {
$scope.materialList = [];
var materialId;
for (materialId in idsList) {
if (idsList[materialId] == true) {
$scope.materialList.push({
'materialId' : parseInt(materialId, 10)
});
}
}
}
、これをキャプチャする機能を追加する必要があなたはplsはあなたのコードスニペット –
を表示することができますI私のポストにHTMLとJSのコードを追加しました。それを見てください。 – CrazyMac
@CrazyMacこれはうまく動作する運がありましたか?他の方法で助けてもらえますか? –