1

I need to do an autocomplete with Nativescript, but I did not find anything on the internet, what I need is that when typing, I send the typed text to an API, all I find is with an existing array. Has anyone ever been through something and come up with a solution?

Rafael Augusto
  • 467
  • 2
  • 12
  • 28
  • 1
    please share some code sample. What have you done till now? and where are you failing? – Ashish Dec 20 '18 at 12:15
  • @Ashish I did not do anything the same, but I tried to use nativescript-ui-autocomplete that gave an error when running my application, so I took it. – Rafael Augusto Dec 20 '18 at 12:24
  • please check out this link [github](https://github.com/Mohamed-saed/autocomplete-input-javascript) is using jquery but you can retype it easily to native javascript – Mohamed Sa'ed Dec 20 '18 at 12:35

2 Answers2

3

Install

npm install nativescript-autocomplete

Usage

IMPORTANT: Make sure you include xmlns:ac="nativescript-autocomplete" on the Page element

e.g

item:Array<string> = ['1','2','3','4']
itemTapped(args){
    const eventName = args.eventName;
    const data = args.data;
    const view = args.view;
    const index = args.index;
    const object = args.object;
}
<ac:Autocomplete  items="{{list}}" itemTap="itemTapped"/>

Source:https://github.com/triniwiz/nativescript-autocomplete See this in case you have problem :https://github.com/triniwiz/nativescript-autocomplete/issues/8

I_Al-thamary
  • 3,385
  • 2
  • 24
  • 37
  • whenever I try to use the error to generate the version `FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:runSbg'. > Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_192.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1 * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. * Get more help at https://help.gradle.org` – Rafael Augusto Dec 20 '18 at 12:37
  • @RafaelAugusto it seems that the problem with the JDK version. – I_Al-thamary Dec 20 '18 at 12:39
  • this appears on the terminal as well. `nativescript-ui-autocomplete 4.2.0 for android is not compatible with the currently installed framework version 4.1.3.` – Rafael Augusto Dec 20 '18 at 12:40
  • See this :https://github.com/shyiko/ktlint/issues/111 and this :https://stackoverflow.com/questions/29756188/java-finished-with-non-zero-exit-value-2-android-gradle/32400904 – I_Al-thamary Dec 20 '18 at 12:41
  • Try to use :`var nativescriptUiAutocomplete = require("nativescript-ui-autocomplete" )` and specific the version that compatible with your android. – I_Al-thamary Dec 20 '18 at 12:44
  • See this:https://github.com/telerik/nativescript-ui-feedback/issues/741 – I_Al-thamary Dec 20 '18 at 12:49
  • without success in all links, funny is that if I take the plugin, it works again, when I put that breaks – Rafael Augusto Dec 20 '18 at 12:56
  • The plugin above only supports Android. – bkulov Mar 24 '21 at 18:31
  • I think the new version support because before it was in their TODO plan. See https://github.com/chrum/nativescript-autocomplete-x – I_Al-thamary Mar 24 '21 at 18:45
0

Checkout RadAutoCompleteTextView

Install

tns plugin add nativescript-ui-autocomplete

Supports Angular & Vue too.

Since you mentioned you will have an api that will return the values, you must need Async Data.

More examples can be found in the Github repo.

Manoj
  • 21,753
  • 3
  • 20
  • 41