从HTML获取dynamic路由input
我正在使用ejs作为模板语言。
<main class="content"> <% documents.forEach(function(documentObject) { %> <h1><a href="/showprofile/:username"><%= documentObject.username %></a> solved </h1> <h2><%= documentObject.problem_id %>. <%= documentObject._statement %> in <%= documentObject.time %> seconds on <%= documentObject.date_added %> . </h2> <% }) %> </main>
我正在使用dynamic路由/showprofile/:username
redirect/showprofile/:username
。 我需要以这样的方式创build超链接,使得documentObject.username
的值作为parameter passing给:username
。 我怎样才能做到这一点 ?
您只需使用ejs函数在您的href属性中呈现用户名,而不是:username
:
<h1><a href="/showprofile/<%= documentObject.username %>"><%= documentObject.username %></a> solved </h1>
- 如何在视图中创buildhref链接,指向Express路由?
- 使用Socket.io刷新页面上的数据而无需重新加载
- 你如何重构嵌套callback,并将parameter passing给节点中的每个函数?
- 将自定义属性添加到Express应用程序和请求。 什么是最好的方法?
- 使用NodeJS作为HTTP服务器 – 如何避免spagetti?
- Node.JS是否有ERB引擎?
- 在快速应用程序的模型中创buildMySql模式
- 如何在expressjs中触发路由器error handling程序而不是默认error handling程序
- 在mongoose schema nodejs中按ObjectIdsearch