我正在使用多个选择框动态创建行,作为Angularjs 1.7.5中的表单字段之一。
每行有两个[选择并选择输入框]
查看:
<select name="inoutvaluedy" class="custom-select" multiple ng-model="available" ng-options="client as client for client in availableclients"></select>
<button id="moveright" class="btn_arrow_style" type="button" value="Add Client" ng-click="additem(available)"></button>
<button id="moveleft" class="btn_arrow_style" type="button" value="Remove Client" ng-click="removeitem(input)"></button>
<select name="selectedclients" class="custom-select" multiple ng-model="input" ng-options="client as client for client in selectedclients"></select>
控制器:
$scope.availableclients = ["fromEmail", "toEmail", "Content"];
$scope.selectedclients = [];
$scope.columns = [{id: 1, input:$scope.selectedclients}];
$scope.addNewColumn = function() {
var newItemNo = $scope.columns.length + 1;
$scope.columns.push({
id: newItemNo,
input: $scope.selectedclients
}); };
//Add item to selected
$scope.additem = function(items) {
items.forEach(function(item) {
$scope.selectedclients.push(item);
$scope.availableclients.splice(items, 1);
});}
//Remove item from selected
$scope.removeitem = function(items) {
items.forEach(function(item) {
$scope.selectedclients.push(item);
$scope.availableclients.splice(item, 1);
});}
问题: 添加行时。重复执行同一项的多个选择框。我需要在每一行上都有一个唯一的选定项。
可能是我的方法是错误的。请看看我的矮人,并纠正我。在此先感谢