Angular自动完成的参数化服务器url

Parametrized server url for Angular autocomplete

本文关键字:参数 服务器 url Angular      更新时间:2023-09-26

我想使用一个自动完成字段

<angucomplete-alt id="members"
              placeholder="Search members"
              pause="400"
              selected-object="testObj"
              remote-url="http://myserver.com/api/user/find?s="
              remote-url-data-field="results"
              title-field="firstName,surname"
              description-field="email"
              image-field="profilePic"
              input-class="form-control form-control-small"/>

但我有几个环境,我必须使用它开发,测试等。

我想知道如何添加远程url

remote-url="http://myserver.com/api/user/find?s="

作为变量…因此根据环境,我可能有

http://my_DEV_server.com/api/user/find?s=

http://my_TEST_server.com/api/user/find?s=

既然这是不同的,然后服务器端渲染在哪里它已经足够/用户/发现?S,如何通过客户端渲染来解决这个问题。

谢谢

成功了:

  <div class="padded-row">
        <div angucomplete-alt id="searchCall" placeholder="Search calls"
             pause="500" selected-object="selectedCall"
             remote-url="/export-proposals/rest/calls"
             remote-url-data-field="call" title-field="name"
             remote-url-request-formatter="remoteUrlRequestFn"
             description-field="callIdentifier" minlength="3"
             input-class="form-control form-control-small" match-class="highlight">
        </div>
    </div>