javascript - AngularJS html 页面如何设置 href 来使用上下文路径?

标签 javascript html angularjs

我正在考虑在 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/

相关文章:

javascript - 附加到 IE 中的正文问题

javascript - 使用 jQuery 在 Jinja2 循环内提供 onclick 事件

javascript - AngularJS 编译不一致

javascript - Angular Binding 不适用于 HTML 中的选择框

javascript - material-ui react.js 中带有评级值的错误

javascript - 自定义 javascript/jquery 不适用于 Angular View

javascript - 检查多个复选框 jQuery

html - float 元素内的垂直居中对齐图标

javascript - DNA 配对、阵列

javascript - 使用 Angular 将 json 对象中的通用文本字符串转换为有效的 url