I'm working on a web app where I'm using an object array to declare values that I will print out using <p ng-repeat="var game in download.game">{{value}}, {{value}}</p>
and so on.
I also wanted to use a download button for the user to download the files. But using a normal a
element, I could only add one link to a specific file. So I was wondering how I could assign a variable to my link so that I could instead have {{download-link}}.
Any suggestions?
答案 0 :(得分:1)
试试这个:
控制器:
$scope.data = [
{
link: "http://link.com",
text: "link.com"
},
{
link: "http://link1.com",
text: "link1.com"
},
{
link: "http://link2.com",
text: "link2.com"
}
];
查看:
<div ng-repeat="element in data">
<a href="{{element.link}}">{{element.text}}</a>
</div>
Codepen: http://codepen.io/anon/pen/LGZrMm
答案 1 :(得分:0)
我不确定我的问题是否正确,但尝试类似:
<div ng-repeat="var game in download.game">
<a ng-href="{{game.link}}">{{game.value1}}, {{game.value2}}</a>
</div>
成为game.link
,其他变量是您要打印的变量。
您应该尝试避免将Angular
变量打印到非角度属性中。因此,请尝试使用ng-href
,ng-click
等。