2016-05-17 6 views
2

私は、アンコンプリートAlt指令を使ってオートコンプリートを作成します。 これまでは問題なく動作していますが、私のサーバーに特定の要求を出したいと思っています。 /検索/ユーザー/名?S =Angucomplete Alt url remote

<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> 

他の言葉では、私は私のサーバーに要求を送信する前に点在するすべてのスペースを変更したいです。

ありがとうございました!

答えて

2

文字列を変更してサーバーに送信する前に、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> 

$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}); 
} 
+0

は、それが正常に動作する、ありがとう:) – mesmed

0

使用リモートAPI-ハンドラ:

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