npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ng4-auto-complete

v1.0.0

Published

An Auto-Complete Module for Angular 4 with extended features and make life easy.

Downloads

378

Readme

ng4-auto-complete

Note - For Angular 5 please reffer to this NG5-AUTO-COMPLETE

This Module can be use when you want Auto-Complete Functionality on your INPUT Tag in the Angular4 Enviroment.

You can use with Reactive Angular Forms or with simple forms with ngModel directive.

1

2

3

Installation -


        npm install --save ng4-auto-complete

What it provides is -

  • WORKS with REACTIVE-ANGULAR FORMS,NORMAL-FORMS,[(ngModel)]
  • RUN on Array of Strings Array<String> or an Objects Array<Object>.
  • Open the Auto-List on Number of Word-Length you have Typed. Default 0
  • How many List-Members to be shown from Matches. Default 15
  • What Should be the TEXT on NO RECORD FOUND. Default ''

Works On -

  • TAP or CLICK
  • TAB KEY
  • ENTER KEY
  • ON BLUR

How to Start with it -

Please include these scripts in your main index.html.


    <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
    <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
    <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>

Now Import the AutoCompleteModule in your main NgModule of your application

and insert this module in your imports array of NgModule.


  //main module
  
  import { AutoCompleteModule } from 'ng4-auto-complete';
  @NgModule({
      imports :[
          AutoCompleteModule
      ]
  })

Its time to Integrate this module in your HTML INPUT Tag


    <input id="list" [ng4-auto-complete]="list">

This will provide the list of 15 best match from provided list.

Here are the Extented features -

  • [word-trigger] -

This is use when you want to open list on perticular word count. It Accepts Number. Default value = 0;

Example- [word-trigger]="2"

  • [list-length] -

This is use when you want to set the length of list which will open. It Accepts Number. Default value = 15;

Example- [list-length]="10"

  • filterName -

Only use when you are providing object List as Array<Object>. which thing to filter from object and show that. [{ name:"hardy", hobby:"coding"},.....] , here if filterName is name then name is filtered and shown on input tag.

Example- filterName="name"

NOTE -

If you not provide the filtername on providing the array list of objects it will throw ERROR.

  • no-record-text -

This is use when you want to show when no record found.

Example - no-record-text="No Records Found!"

USED AS -


<input style="margin: 40px;" id="list"
[ng4-auto-complete]="countryList" 
[word-trigger]="2" [list-length]="10"
filterName="name" no-record-text="No Records Found!" >

Set Dynamic List -

For Dynamic List we can inject the Service i.e AutoCompleteService

in your component and set it when you get the list like this -

  import { AutoCompleteService } from 'ng4-auto-complete';
  
  export class YourComponent{ 

      constructor(public autoCompleteService: AutoCompleteService){ }

      //call this method when you get list from anywhere
      setList(list){
          this.autoCompleteService.setDynamicList(list);
          // this will log in console if your list is empty.
      }
  }

Update List -

For Update List we can inject the Service i.e AutoCompleteService

in your component and set it when you get the list like this -

  import { AutoCompleteService } from 'ng4-auto-complete';
  
  export class YourComponent{ 

      constructor(public autoCompleteService: AutoCompleteService){ }

      //call this method when you want to update list from anywhere
      //elementId ,is the id od input tag which you want to change

      updateList(list,elementId){
         this.autoCompleteService.updateList(list, elementId);
      }
  }

NOTE -

  • It always sets String in the input ( on any list( String or Object ) )
  • The List Above Should be of Array of Strings or Objects.
  • The Input Id should be Unique in your HTML page.

Contributions are most Wellcome.