简体   繁体   English

简单的MEAN Stack问题

[英]Simple MEAN Stack issue

I have a express route; 我有一条快速路线; router.get('/uni/: queryst ', function (req, res) { var choice = req.params.queryst);} router.get('/ uni /: queryst ',function(req,res){var choice = req.params.queryst);}

Where basically I use the queryst value from the URL to use it to query something in my database. 基本上,我使用URL中的queryst值来查询数据库中的内容。 On the front end, I need to have an input field where the user types the choice and hits submit and then it translates to something like /uni/valuehere on the browser and sending GET to express where it gets caught by the router I wrote above. 在前端,我需要有一个输入字段,用户可以在其中输入选择并点击提交,然后在浏览器上将其转换为类似/ uni / value的内容,并发送GET表示它被我上面编写的路由器捕获了。 I don't know how can I make the input field of HTML turn into a URL of the format /uni/valuehere . 我不知道如何使HTML的输入字段变成/ uni / valuehere格式的URL。

As for testing the code initially I was directly typing the URL manually with the value I intended to verify to check if the data passed. 至于最初的代码测试,我直接手动输入URL 并输入要验证的值以检查数据是否通过。 Well, users are not going to type URL's directly to search, they will need a form and that is what I can't get my head around to how to turn the input field into a URL in a format /uni/WhateverTheUserHasTypedInTheFieldShouldAppearHere 好吧,用户不会直接键入URL来搜索,他们将需要一种形式,这就是我无法理解如何将输入字段转换为格式为/ uni / WhateverTheUserHasTypedInTheFieldShouldAppearHere的URL的原因

Thanks in advance for the help. 先谢谢您的帮助。 I am self learning the MEAN stack and have come a long way. 我正在自学MEAN堆栈,并且已经走了很长一段路。 I need support of experienced developers as I am currently stuck here. 我目前在这里,所以需要经验丰富的开发人员的支持。

While sending the request write (in controller): 发送请求时,写(在控制器中):

$http.get('/uni/'+queryst).success(function(response){

    // Write code using response

});

While on the server side write: 在服务器端写:

$http.get('/uni/:queryst',function(req,res){
var choice= req.params.queryst
// Code ....

});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM