gpt4 book ai didi

javascript - Angucomplete Alt url 远程

转载 作者:行者123 更新时间:2023-11-27 23:28:18 25 4
gpt4 key购买 nike

我使用 Angucomplete Alt 指令进行自动完成。到目前为止它工作正常,但我想向我的服务器发出特定请求。/搜索/用户/名称?s=

<div angucomplete-alt
id="input-name"
placeholder="Name"
pause="50"
search-fields="name"
remote-url=/users/name?s=
title-field="name"
minlength="3"
match-class="angucomplete-match">
</div>

换句话说,我想在将请求发送到我的服务器之前将所有空格更改为点。

提前致谢!

最佳答案

您可以使用 remote-api-handle 选项在将字符串发送到服务器之前对其进行修改。

<div angucomplete-alt
id="input-name"
placeholder="Name"
pause="50"
search-fields="name"
remote-url-handler="searchAPI"
title-field="name"
minlength="3"
match-class="angucomplete-match">
</div>

在你的 Controller 中:

$scope.searchAPI = function(userInputString, timeoutPromise) {
//Modify input before it gets sent to the server
userInputString = userInputString.replace(' ', '.');
return $http.post('/users/name', {s: userInputString}, {timeout: timeoutPromise});
}

关于javascript - Angucomplete Alt url 远程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37274566/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com