【发布时间】:2017-02-28 23:19:05
【问题描述】:
我有一个动态 URL,在我的 html 中我想做这样的事情:
<a onclick="location.href='myVariable';"><span>Click here</span></a>
这会在 URL 中拼出单词“myVariable”,而不是使用我的变量的值。我也试过:
<a onclick="location.href='{{myVariable}}';"><span>Click here</span></a>
我使用了方括号,因为我的应用程序使用的是 angularJS,但这也不起作用。
有没有办法在 HTML 中做到这一点?而不是使用 onclick javascription 函数?
感谢任何帮助!
【问题讨论】:
标签: html angularjs variables location href