我正在使用 Angular js; 在我的 View 模板中,我有一个表 我希望表格中由模型中的元素填充的每一行都可以链接到另一个页面。 我尝试了注释的代码行,但它不起作用!
感谢您的帮助! 干杯!
<section data-ng-controller="AllsController" data-ng-init="find()">
<div class="page-header">
<h1>Alls</h1>
</div>
<div class="list-group">
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>Created</th>
<th>User</th>
<th>Name</th>
<th>Color</th>
</tr>
</thead>
<tbody>
<tr data-ng-repeat="all in alls">
<!-- <a data-ng-href="#!/alls/{{all._id}}" > -->
<td data-ng-bind="all.created | date:'medium'"></td>
<td data-ng-bind="all.user.displayName"></td>
<td data-ng-bind="all.name"></td>
<td data-ng-bind="all.color"></td>
<!-- </a> -->
</tr>
</tbody>
</table>
</div>
最佳答案
你可以做类似的事情
<tr ng-click="onClick()">
在您的 onClick 函数中,您可以编写您的逻辑。如果你想重定向到某个页面,你可以使用 angularjs 的 $location 服务。
关于Table Angular js中的HTML链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30400820/