【发布时间】:2017-06-19 05:06:47
【问题描述】:
我正在使用 angular.js 创建一个动态表,其中填充了一项研究的结果。如果用户单击表中的特定行,我需要能够显示有关每项研究的更多数据。这是表格的样子。我想我必须使用 ngOptions 或 ngSelect,但我不确定。非常感谢任何帮助。
<table class="table table-condensed table-hover">
<thead>
<tr>
<td class="center" id="table-header">Date</td>
<td class="center" id="table-header">Study</td>
<td class="center" id="table-header">Sample</td>
<td class="center" id="table-header">File</td>
<td class="center" id="table-header">Big Data</td>
<td class="center" id="table-header">Action</td>
</tr>
</thead>
<tbody ng-repeat="study in studies | filter: filter_name">
<tr>
<td class="center">{{ study.created_at }}</td>
<td class="center">{{ study.study }}</td>
<td class="center">{{ study.sample }}</td>
<td class="center">{{ study.fastq }}</td>
<td class="center">{{ study.bigData }}</td>
<td class="center">
<div class="dropdown center">
<button id="dLabel" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Action
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="dLabel">
<li id="list-item">Continue</li>
<li id="list-item" data-toggle="modal" data-target="#more-metadata-modal">More Data</li>
<li id="list-item" data-toggle="modal" data-target="#edit-metadata-modal">Edit</li>
<li id="list-item" data-toggle="modal" data-target="#delete-metadata-modal">Delete</li>
</ul>
</div>
</td>
</tr>
</tbody>
</table>
【问题讨论】:
-
几个通知首先,
ng-repeat应该在<tr>中,因为那是您想要重复(行)的内容,对吗?您也有许多具有相同id属性的元素,id 必须是唯一的。那么如何获取 更多数据,例如通过 ajax 调用或者它们是已知的?
标签: javascript angularjs html-table