我正在考虑在 html 文件中编写如下内容:
<a id="homeId" class="navbar-brand" href="javascript:document.write('${pageContext.request.contextPath}')">Root Page</a>
在浏览器中,我看到的链接是实际的 href 字符串未评估,即:
javascript:document.write('${pageContext.request.contextPath}')
最佳答案
您需要在变量周围使用双花括号:{{}}
我不确定您要做什么,但这是一个显示正在评估的变量的简单示例:
http://plnkr.co/edit/cUckEApeSLI7t4jGJcw5
请注意,它只是将值更改为“test”。
关于javascript - AngularJS html 页面如何设置 href 来使用上下文路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23176878/