I have an angular app in which there's a table that includes something of the general form:
<tr ng-repeat='d in data'>
<td>{{d.foo}}</td>
</tr>
I'd like to use the value of d.foo (which, for example, could be Bicycle to turn the cell into a link to a website like http://en.wikipedia.org/wiki/Bicycle. I've tried to find an answer to this on SO already but have had no luck; my apologie if I just didn't see it.
Is it possible to do the described task? If so, any pointers or suggestions?
asked Jul 24, 2013 at 10:47
user139014
1,4952 gold badges20 silver badges33 bronze badges
2 Answers 2
Use:
<td><a ng-href="http://en.wikipedia.org/wiki/{{d.foo}}">{{d.foo}}</a></td>
You can read more here: http://docs.angularjs.org/api/ng.directive:ngHref
;)
answered Jul 24, 2013 at 10:52
Ivan Chernykh
42.2k13 gold badges136 silver badges149 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
Use it in a <a> tag.
For example:
<a href="http://your_url/{{d.foo}}">{{d.foo}}</a>
answered Jul 24, 2013 at 10:51
Atropo
12.6k8 gold badges51 silver badges62 bronze badges
Comments
lang-html
<td><a ng-href="http://en.wikipedia.org/wiki/{{d.foo}}">{{d.foo}}</a></td>?