如何从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); });