如何从angularjs $ http发送点字符作为参数
我正在尝试发送.
(点)作为一个string在Nodejs中的以下aspi调用。 我正在使用Angularjs $http
对象。
我可以看到正在使用我在search框中input的点号(。)字符进行调用。
https:// localhost:3003 / posts / search / 。
但是,当我通过谷歌开发人员工具看到ajax调用时,它正在调用:
https://开头本地主机:3003 /职位/search/
我怎样才能传递一个点字符?
代码是:
返回
$http.get('https://localhost:3003/posts/search/.').then(getPostCompleted).catch(function (message) { handleException(message); });
我不认为我必须在这个?
谢谢
你应该使用类似的东西得到参数:
https://localhost:3003/posts/search?req=.
并获得您的代码中的req
参数。 我知道这不是你想要的路线,但我认为这个点是一个特殊的angular色,不会在路线中使用,因为它是用于域
我怎样才能传递一个点字符?
URL中的string将被url编码 。 原始的JavaScript有一个这样做的function ,但angular.js $ http服务有这个特殊的行为 。
编辑:
我可以看到正在使用我在search框中input的点号(。)字符进行调用。
https:// localhost:3003 / posts / search / 。
但是,当我通过谷歌开发人员工具看到ajax调用时,它正在调用:
https://开头本地主机:3003 /职位/search/
Chrome浏览器必须在默认情况下剥离点而不扩展。 正则expression式parsing它的地方也许。
看到这个关于使用点。
如果你想使用GET,那么你可以传递参数作为查询stringie
$http.get('https://localhost:3003/posts/search?string=.') .then(getPostCompleted).catch(function (message) { handleException(message); });
否则,您可以使用POST并将该参数添加到正文
$http.post('https://localhost:3003/posts/search', {string: '.'}) .then(getPostCompleted).catch(function (message) { handleException(message); });
- 后端文件被公开加载 – Angularjs / Node / Gulp
- NodeJS服务器检索部分时返回505/404错误
- Angular JS将base64数组发送到NodeJs服务器 – Allow-Access-Control-Origin
- 在使用Angular的单页面应用程序引擎时,依靠socket.io/express.io中的“disconnect”事件
- socket.io不能在Chrome移动设备上工作,但它在隐身模式下工作
- 我如何使用angularjs从物理path下载Excel文件
- CORS节点js问题
- 在JavaScript中不使用数字占位符复制C#的string.format()
- Multer不接受数组格式的文件会导致“Unexpected File Error”