使用ng-repeat
创建的表中有多行。每一行都有一个下拉列表。我希望在下拉列表中获取选定的值,并使用JavaScript或JQuery单击“下一步”按钮将该值与该行中的其他相应值附加到字符串格式中。例如:“one,B:two,B:three,A:four:C”(在这个例子中,假设B选择下拉第一行,其他行类似逻辑)查找表中每行的下拉列表的选定值
以下是HTML代码片段:
<div class="mainDiv" ng-controller="myController">
<div class="div1">
<table class="table myTable">
<thead>
<tr>
<th>
<center>serial</center>
</th>
<th>
<center>data</center>
</th>
<th>
<center>aplhabet</center>
</th>
</tr>
</thead>
<tbody class="myTableBody">
<tr ng-repeat="data in myData" id="{{$parent.$id+'-'+$index}}">
<td>{{$index + 1}}</td>
<td>{{data}}</td>
<td>
<select>
<option value="Select">-- Select --</option>
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
</select>
</td>
</tr>
</tbody>
</table>
</div>
<div class="div2">
<button type="button" class="btn btn-md btn-primary btnNext">Next</button>
</div>
</div>
和下面是angularJS部分:
myApp.controller('myController', function ($scope) {
$scope.myData = ["one","two","three","four"];
});
需要{{数据}},每行下拉的选定值。例如在表 串行数据\t字母一个\t乙乙Ç甲 预期结果:“一个,B:2,B:3 ,A:4:C” –