JDH*_*JDH 8 angularjs angularjs-ng-repeat
我正在尝试使用angular来创建一个由主题,日期,演示者组织的不同视频的表格,并且还会被标记.
我使用ng-repeat重复我的对象数组来生成一个表.
但是,如何动态更改播放按钮的href链接?
在下面的jsfiddle中,我添加了一个静态行,每行应该是什么样子.第一列有一个链接到视频的fontawesome图标.如何编辑函数以便在ng-repeat中更新href链接?
http://jsfiddle.net/jheimpel/f139z9zx/3/
function playerCtrl($scope) {
$scope.topics = [
{
"play": "play",
"topic": "topic 1",
"date": "date 1",
"presenter": "presenter 1",
"tags": "tag"
},
{
"play": "play",
"topic": "topic 2",
"date": "date 2",
"presenter": "presenter 2",
"tags": "tag"
},
];
}
Run Code Online (Sandbox Code Playgroud)
dol*_*ldt 15
您可以在ng-repeat中放置带有动态href的<a>标签,它可以正常工作 - 尽管使用ng-href更好,因此在数据绑定准备好之前,您的链接不会中断.
我已经更新了你的小提琴:这里
因此ng-repeat开头于:
<tr ng-repeat="topic in topics">
<td><a ng-href="#/{{topic.url}}"><i class="fa fa-play"></i></a></td>
Run Code Online (Sandbox Code Playgroud)
(我在测试数据中添加了额外的url字段)
| 归档时间: |
|
| 查看次数: |
20904 次 |
| 最近记录: |