CompleterService customization for remote data


Topic: CompleterService customization for remote data

Anne-Nora Chavanes pro asked 6 months ago

I am cloning the AutocompleteComponent from ng-uikit-pro-standard-7.4.0\projects\mdb-demo\src\app\components\forms\autocomplete\ directory into my app.

After every keystroke, I'd like to append a '*' to the URL, indicating to my HTTP service, that this is a LIKE operation, not a WHERE, e.g. http://localhost/api/Person/Smith*

What would be the best way to do this, please?

Is there a way to specify a URL suffix that always gets appended to the service URL?


Arkadiusz Idzikowski staff answered 6 months ago

You can try something like this:

  public dataRemote: RemoteData;

  constructor(private completerService: CompleterService) {

    this.dataRemote = completerService.remote('apiUrl', 'name', 'name');
    this.dataRemote.urlFormater(input => {
      return `myUrl/${input}*`;
    });

  }

Anne-Nora Chavanes pro answered 6 months ago

Awesome. Worked great. Thx.


Please insert min. 20 characters.
Status

Resolved

Specification of the issue
  • User: Pro
  • Premium support: No
  • Technology: Angular
  • MDB Version: 7.0.0
  • Device: PC
  • Browser: Chrome
  • OS: Windows 10
  • Provided sample code: No
  • Provided link: Yes