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

ng2-typeahead-startswith

v1.2.2

Published

A simple Angular2 typeahead/autocomplete component with no third-party dependencies.

Downloads

7

Readme

[deprecated] ng2-typeahead-startswith npm version

A simple Angular2 typeahead/autocomplete component.

This package is no longer being developed.

See ng2-typeahead on GitHub

Angular 2 Style Guide Join the chat at https://gitter.im/brinkmanjg/ng2-bootstrap Dependency Status devDependency Status Throughput Graph

Installation

  1. A recommended way to install ng2-typeahead is through the npm package manager using the following command:

npm i ng2-typeahead --save

Alternatively, you can download it in a ZIP file.

  1. Currently ng2-typeahead contains one directive: typeahead.

Example

my.component.ts
import { Typeahead } from 'ng2-typeahead';

@NgModule({
   declarations: [ Typeahead ],
})

@Component({
    selector: 'my-component',
    template: require('./my.component.html'),
    styles: [`
        .typeahead-input,
        .typeahead-typeahead{
            width: 250px;
            padding: 8px;
            border-radius: 5px;
        }
    `]
})
export class MyComponent {

  fruitName: string;
  fruits: any[] = [
    {
      id: 1,
      name: "Apple",
      searchText: "apple"
    },
    {
      id: 2,
      name: "Orange",
      searchText: "orange"
    },
    {
      id: 3,
      name: "Banana",
      searchText: "banana"
    }
  ];

  selectedFruit: any = this.fruits[0];

  public fruitSelected(fruit) {
    this.fruitName = fruit ? fruit.name : 'none';
  }

}
my.component.html
<typeahead
  [(ngModel)]="selectedFruit"
  [list]="fruits"
  [searchProperty]="'searchText'" [displayProperty]="'name'"
  [maxSuggestions]="2"
  (suggestionSelected)="fruitSelected($event)"
  placeholder="Begin typing a fruit">
</typeahead>

<p>You selected {{ fruitName }}</p>

The following adjustments may be required in systemjs.config.js to run the example code. Issue #7

var map = {
    ...
    'ng2-typeahead':              'node_modules/ng2-typeahead',                             
  };
  ...
  var packages = {
    ...
    'ng2-typeahead':              { main: 'ng2-typeahead.js', defaultExtension: 'js' }
  };
Demo

API for typeahead

This is the only directive. Provide a list of suggestions as an object array, specify the display and search properties, and handle the selection event however you like.

Properties

Binding Property | Type | Remarks ------------ | ---------- | ------------- [(ngModel)] | any | The model property to which the component is bound. Optional. [list] | any[] | The complete list of items. These can be any type of object. This is required. [displayProperty] | string | The property of a list item that should be displayed. The default is 'name'. [searchProperty] | string | The property of a list item that should be used for matching. The default is 'name'. [maxSuggestions] | number | The maximum number of suggestions to display. The default is -1 (no limit).

Note: displayProperty and searchProperty can be the same property or different properties based on your needs.

Events

Event Binding | Remarks ------------ | ------------- (suggestionSelected) | Called when a suggestion has been selected. The only parameter is the selected item.

Styles

Selector | Remarks ------------ | ------------- .typeahead | The outer div which holds all component elements. .typeahead-input | The input element into which the user enters text. .typeahead-input-has-selection | The input element into which the user enters text when a suggestion is selected. This alerts the user that a selection has been made. .typeahead-typeahead | The type-ahead input element which displays the suggested text. .typeahead-suggestions | The div which holds the suggestions elements. .typeahead-suggestions ul | The unordered list of suggestions. .typeahead-suggestions ul li | The individual suggestion elements. .typeahead-suggestion-active | The active (highlighted) suggestion in the suggestions list.

Troubleshooting

Please follow this guidelines when reporting bugs and feature requests:

  1. Use GitHub Issues board to report bugs and feature requests (not our email address)
  2. Please always write steps to reproduce the error. That way we can focus on fixing the bug, not scratching our heads trying to reproduce it.

Thanks for understanding, and apologies for any issues experienced thus far.

License

The MIT License (see the LICENSE file for the full text)