基于JSON属性创建链接

时间:2014-11-19 06:05:42

标签: c# json angularjs

我获得了一个在UI中显示的JSON序列化字符串。我想基于一些参数将特定属性显示为超链接。解决这个问题的最佳方式是什么?

2 个答案:

答案 0 :(得分:0)

使用ng-href

documentation

<a ng-href="{{valueFromController}}">link</a>

在角度控制器中,

$scope.valueFromController = "https://www.google.com"; // change the value according to your conditions.

答案 1 :(得分:0)

ng-href(参见文档here

您可以在html标记中定义链接,如此

<a ng-href="http://www.gravatar.com/avatar/{{yourJsonObject.property}}">link1</a>

其中yourJsonObject是$ scope

中的javascript对象