演示:http://plnkr.co/edit/ktnDiUSA7eU7DNkIbTqo
<ul>
<li ng-repeat="thread in data">
<a href="{{thead.url}}" target="_blank">
{{thread.title}}
</a>
</li>
</ul>
我得到了这样的json
$scope.data = [
{
"title": " 'Aku kecewa, tiada harapan kalahkan DAP'",
"desc": "BACKER QUITS ?",
"starter": "rhoyo",
"replies": " 23 ",
"url": "https://forum.lowyat.net/Kopitiam/topic/3235530"
},
{
"title": " Angry China launches war against terror ",
"desc": "",
"starter": "rivost",
"replies": " 6 ",
"url": "https://forum.lowyat.net/Kopitiam/topic/3235746"
}
];
为什么当我{{thread.url}}
确实打印出直接网址?
答案 0 :(得分:0)
您需要使用Angular ng Href指令。只需将href
替换为ng-href
。
答案 1 :(得分:0)
首先,你应该修正拼写错误thread.url
而不是thead.url
然后将href
属性替换为ng-href
<a ng-href="{{thread.url}}" target="_blank">
{{thread.title}}
</a>