All Projects → brinkmanjg → Ng2 Typeahead

brinkmanjg / Ng2 Typeahead

Licence: mit
Autocomplete component for Angular 2

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Ng2 Typeahead

Fluent Plugin Grep
(Deprecated) Fluentd output plugin to grep messages
Stars: ✭ 17 (-48.48%)
Mutual labels:  deprecated
Ng Suggest
AngularJS module to provide Typeahead via OpenSearch Suggestions
Stars: ✭ 9 (-72.73%)
Mutual labels:  deprecated
Prey Bash Client
DEPRECATED - Project no longer supported, please consider using https://github.com/prey/prey-node-client instead
Stars: ✭ 882 (+2572.73%)
Mutual labels:  deprecated
Materialdrawer Xamarin
DEPRECATED!!! Xamarin bindings for https://github.com/mikepenz/MaterialDrawer
Stars: ✭ 22 (-33.33%)
Mutual labels:  deprecated
Otc Tools
(Deprecated) Simple bash/curl/jq based command line tool using the OpenStack and OTC specific REST APIs.
Stars: ✭ 26 (-21.21%)
Mutual labels:  deprecated
Deobfuscator
[Not work] Deobfuscate obfuscated binaries!
Stars: ✭ 11 (-66.67%)
Mutual labels:  deprecated
Localart
An HTML5 mobile app for navigating & browsing locations of public art, architecture, and culture in Norfolk, VA.
Stars: ✭ 5 (-84.85%)
Mutual labels:  deprecated
Finder colors
Set the color of files/folders for OSX Finder from the command line.
Stars: ✭ 31 (-6.06%)
Mutual labels:  deprecated
Madalynnplumbundle
The deploy bundle using Plum for Symfony2
Stars: ✭ 26 (-21.21%)
Mutual labels:  deprecated
Startssl api
DEPRECATED A python/CLI API for some StartCom StartSSL functions
Stars: ✭ 14 (-57.58%)
Mutual labels:  deprecated
Doctrinemigrations
[DEPRECATED] Use Phinx instead
Stars: ✭ 24 (-27.27%)
Mutual labels:  deprecated
Esp32 Http Update
Clone of https://github.com/esp8266/Arduino/tree/master/libraries/ESP8266httpUpdate for ESP32
Stars: ✭ 25 (-24.24%)
Mutual labels:  deprecated
Grunt Csswring
DEPRECATED. Minify CSS files using PostCSS-based CSSWring
Stars: ✭ 12 (-63.64%)
Mutual labels:  deprecated
Gamejoltlua
Access to GameJolt's opportunities for all your lovely Lua projects.
Stars: ✭ 18 (-45.45%)
Mutual labels:  deprecated
Overwatch Js
Overwatch NodeJS API : Retrieve informations about heroes/players from Overwatch Official Website
Stars: ✭ 27 (-18.18%)
Mutual labels:  deprecated
Watset
Watset: Automatic Induction of Synsets from a Graph of Synonyms
Stars: ✭ 16 (-51.52%)
Mutual labels:  deprecated
Sqlite Provider
SQLite3 provider for Vapor
Stars: ✭ 11 (-66.67%)
Mutual labels:  deprecated
Brunch With Vue
[deprecated] A skeleton application utilizing vue, vuex, vue-resource and vue-router.
Stars: ✭ 32 (-3.03%)
Mutual labels:  deprecated
Os Tmpdir
[DEPRECATED] Node.js os.tmpdir() ponyfill
Stars: ✭ 31 (-6.06%)
Mutual labels:  deprecated
Requery
Store e run queries on database to help system manager of a Django website
Stars: ✭ 12 (-63.64%)
Mutual labels:  deprecated

[deprecated] ng2-typeahead 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)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].