Giter Club home page Giter Club logo

ng2-completer's Introduction

ng2-completer

Auto complete component for Angular 2.

This component is based on angucomplete-alt

Click for demo or plunk

Help needed

I don't use this library much anymore and don't have time to properly maintain it. If you are currently using ng2-completer and interested to maintain it please let me know!

Installation

npm install ng2-completer --save

Usage

The module you want to use ng2-completer in must import Ng2CompleterModule and FormsModule (to use the ngModel directive on ng2-completer). Ng2CompleterModule provides the CompleterService, and declares the ng2-completer directive.

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from "@angular/forms";
import { HttpClientModule } from "@angular/common/http";
import { AppComponent } from './app.component';
import { Ng2CompleterModule } from "ng2-completer";


@NgModule({
  imports: [
      BrowserModule,
      FormsModule,
      HttpClientModule,
      Ng2CompleterModule,
  ],
  declarations: [ AppComponent ],
  bootstrap: [ AppComponent ]
})
export class AppModule { }

Add ng2-completer to your component and create a data source:

import { Component } from '@angular/core';
import { CompleterService, CompleterData } from 'ng2-completer';

@Component({
  selector: 'my-component',
  template: `<h1>Search color</h1>
            <ng2-completer [(ngModel)]="searchStr" [datasource]="dataService" [minSearchLength]="0"></ng2-completer>
            <h1>Search captain</h1>
            <ng2-completer [(ngModel)]="captain" [datasource]="captains" [minSearchLength]="0"></ng2-completer>`
})
export class MyComponent {

  protected searchStr: string;
  protected captain: string;
  protected dataService: CompleterData;
  protected searchData = [
    { color: 'red', value: '#f00' },
    { color: 'green', value: '#0f0' },
    { color: 'blue', value: '#00f' },
    { color: 'cyan', value: '#0ff' },
    { color: 'magenta', value: '#f0f' },
    { color: 'yellow', value: '#ff0' },
    { color: 'black', value: '#000' }
  ];
  protected captains = ['James T. Kirk', 'Benjamin Sisko', 'Jean-Luc Picard', 'Spock', 'Jonathan Archer', 'Hikaru Sulu', 'Christopher Pike', 'Rachel Garrett' ];

  constructor(private completerService: CompleterService) {
    this.dataService = completerService.local(this.searchData, 'color', 'color');
  }
}

ng2-completer uses rxjs stream as data sources. There are 2 ready made data sources that can be used to fetch local and remote data but it's also possible to provide a custom source that generates a stream of items.

System.js configuration

Add the following to System.js map configuration:

   var map = {
       ...
       'ng2-completer': 'node_modules/ng2-completer/ng2-completer.umd.js'
   }

API

ng2-completer component

Attribute Description Type Required Default
datasource Autocomplete list data source can be an array of strings or a URL that results in an array of strings or a CompleterData object Array<string>|string|CompleterData Yes
dataService Deprecated use datasource instead. Autocomplete list data source. CompleterData Yes
ngModel see the angular forms API. string Yes
autoMatch Auto select an item if it is the only result and it is an exact match of the search text. boolean No false
autofocus Set input focus when the page loads boolean No false
clearUnselected Clear the input on blur if not selected. boolean No false
clearSelected Clear the input when a result is selected. boolean No false
disableInput If true disable the input field. boolean No false
fieldTabindex Set the tabIndex of the input. number No
initialValue Initial value for the component. Value is parsed using: titleField, descriptionField and imageField and used as selected value any No
inputId id attribute of the input element. string No
inputName name attribute of the input element. string No
inputClass class attribute of the input element. string No
matchClass CSS class to apply for matching part of the title and description. string No
maxChars Maximal number of characters that the user can type in the component. number No 524288
minSearchLength Minimal number of characters required for searching. number No 3
overrideSuggested If true will override suggested and set the model with the value in the input field. boolean No false
openOnFocus If true will open the dropdown and perform search when the input gets the focus. boolean No false
openOnClick If true will open and close the dropdown by click. boolean No false
selectOnFocus If true will select the input text upon focus. boolean No false
selectOnClick If true will select the input text by click. boolean No false
fillHighlighted If true will set the model with the value in the input field when item is highlighted. boolean No true
pause Number of msec. to wait before searching. number No 250
placeholder Placeholder text for the search field. string No
textNoResults Text displayed when the search returned no results. if the string is falsy it won't be displayed string No
textSearching Text displayed while search is active. if the string is falsy it won't be displayed string No Searching...
autoHighlight Automatically highlight the best matching search result when the input changes. the "best match" is selected by: exact match, starts with and finally includes boolean No false

ng2-completer events

Name Description Type
selected emitted when an item is selected. (selected: CompleterItem): void
highlighted emitted when an item is highlighted. (highlighted: CompleterItem): void
focus emitted when the input gets focus (): void
blur emitted when the input looses focus (): void
opened emitted when the dropdown is opened or closed (isOpen: boolean): void
keyup emitted when the input emits keyup (event: any): void
keydown emitted when the input emits keydown (event: any): void

ng2-completer methods

Method Description Parameters
open() Open the dropdown
close() Close the dropdown
focus() Set the focus to the completer input
blur() Remove the focus from the completer input
isOpen() Returns the state of the dropdown

Local data

Create local data provider by calling CompleterService.local.

Parameters

Name Type Description Required
data any[] | Observable<any[]> A JSON array with the data to use or an Observable that emits one Yes
searchFields string Comma separated list of fields to search on. Fields may contain dots for nested attributes; if empty or null all data will be returned. Yes
titleField string Name of the field to use as title for the list item. Yes

Attributes

Name Type Description
descriptionField string Name of the field to use as description for the list item.
imageField string Name of the field to use as image url for the list item.

Remote data

Create remote data provider by calling CompleterService.remote.

Parameters

Name Type Description Required
url string Base url for the search Yes
searchFields string Comma separated list of fields to search on. Fields may contain dots for nested attributes; if empty or null all data will be returned. Yes
titleField string Name of the field to use as title for the list item. Yes

Attributes

Name Type Description
descriptionField string Name of the field to use as description for the list item.
imageField string Name of the field to use as image url for the list item.
urlFormater (term: string) => string Function that get's the searchterm and returns the search url before each search.
dataField string The field in the response that includes the data.
requestOptions RequestOptions (@angular/common/http) HTTP request options that should be sent with the search request.

CSS classes

  • .completer-holder
  • .completer-input
  • .completer-dropdown-holder
  • .completer-dropdown
  • .completer-searching
  • .completer-no-results
  • .completer-row
  • .completer-image-holder
  • .completer-image
  • .completer-image-default
  • .completer-title
  • .completer-description
  • .completer-list-item-holder
  • .completer-list-item
  • .completer-selected-row

Credits

  • This product uses the TMDb API but is not endorsed or certified by TMDb

ng2-completer's People

Contributors

arjenbrandenburgh avatar armno avatar davidwalschots avatar dddent avatar jordivila avatar mdudek avatar mgechev avatar microwavedev avatar nicolasem avatar ofer-papaya avatar oferh avatar rayzru avatar shahor avatar tdesvenain avatar vdurante avatar venikx avatar yggg avatar zladuric avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ng2-completer's Issues

CompleterService.remote().headers() not assignable error

Hey there,

I have some code for running a search query with some headers attached as following:

this.headers = this._users.createHeaders(); this.dataService = completerService.remote('http://localhost:3000/search?q=', 'title', 'title').headers(this.headers);

However, I keep getting an error: Type 'void' is not assignable to type 'CompleterData'. When I remove the .headers() attribute, it doesn't have a problem. I have noticed this with other attributes. Am I doing something wrong? I know the this.headers variable is a Headers object.

Thanks!

documentation for use with remote data service

I have this working successfully with my application, using the demo code with the local data service. Do you have any example of how to use it with a remote data service? I have a REST API to perform the search on a remote database that I'd like to use.

Problem with empty input

Hi, there is problem if I press Enter in empty field

Here is the problem (completer-cmp.ts:158):

public keydownHandler(event: any) {
        if (event.keyCode === KEY_EN && this.results) {
            if (this.listCmp.currentIndex >= 0 && this.listCmp.currentIndex < this.results.length) {

When field is empty, it throws exception, because listCmp is undefined. I'd added one more condition like "if (this.listCmp && ... "

build error at ComponentRef

build error at ComponentRef is not generic for autocomplete.ts where you do private listCmp: ComponentRef = undefined;

VS 2015

Attribute

I am trying to use this package in IonicFramework so for input fields i have to use ion-input.

<ion-input [(ngModel)]="searchStr" [dataService]="dataService" [minSearchLength]="0" [ngModelOptions]="{standalone: true}"></ion-input>

but looks like i have to use <ng2-completer...</<ng2-completer> to make it work. Is it possible to set ng2-completer as an attr?

Support extracting data from Object response

Hi!

I've just used ng2-completer for some day, but when my project require remote search, the data returned from service has many informations, such as:

{
  customers: [
   {
      name: 'user 1',
      age: 20
   },
   { 
      name: 'user 2',
      age: 21
   },
 ],
someObject: [],
someMoreObject: []


}

I just want to looking for data in "customer" array, could ng2-completer support this case?

Thank you!

How to use ng-completer inside directive Form

Hello,

How to use input autocomplete by ng-completer inside formGroup, when I use ng-completer with formGroup it show error:
ngModel cannot be used to register form controls with a parent formGroup directive. Try using
formGroup's partner directive "formControlName" instead.

Please help me, Thanks!

Error Module not already loaded loading "@angular/core"

I did all steps to implement the component, but when running I get this:

localhost/:148 Error: Error: Module not already loaded loading "@angular/core" as http://localhost:5555/node_modules/@angular/core/bundles/core.umd.
at Object.eval (http://localhost:5555/node_modules/ng2-completer/bundles/ng2-completer.js:76:19)
at webpack_require (http://localhost:5555/node_modules/ng2-completer/bundles/ng2-completer.js:30:30)
at Object.c (http://localhost:5555/node_modules/ng2-completer/bundles/ng2-completer.js:371:15)
at webpack_require (http://localhost:5555/node_modules/ng2-completer/bundles/ng2-completer.js:30:30)
at Object.eval (http://localhost:5555/node_modules/ng2-completer/bundles/ng2-completer.js:58:24)
at webpack_require (http://localhost:5555/node_modules/ng2-completer/bundles/ng2-completer.js:30:30)
at eval (http://localhost:5555/node_modules/ng2-completer/bundles/ng2-completer.js:50:18)
at eval (http://localhost:5555/node_modules/ng2-completer/bundles/ng2-completer.js:53:10)
at Object.eval (http://localhost:5555/app/dashboard/tdr/tdr-list.component.js:14:23)
at eval (http://localhost:5555/app/dashboard/tdr/tdr-list.component.js:65:4)
at eval (http://localhost:5555/app/dashboard/tdr/tdr-list.component.js:66:3)
at Object.eval (http://localhost:5555/app/dashboard/tdr/index.js:5:10)
at eval (http://localhost:5555/app/dashboard/tdr/index.js:10:4)
at eval (http://localhost:5555/app/dashboard/tdr/index.js:11:3)
at Object.eval (http://localhost:5555/app/dashboard/dashboard.routes.js:17:16)
at eval (http://localhost:5555/app/dashboard/dashboard.routes.js:29:4)
at eval (http://localhost:5555/app/dashboard/dashboard.routes.js:30:3)
at Object.eval (http://localhost:5555/app/dashboard/index.js:6:10)
at eval (http://localhost:5555/app/dashboard/index.js:10:4)
at eval (http://localhost:5555/app/dashboard/index.js:11:3)
at Object.eval (http://localhost:5555/app/app.routes.js:4:15)
at eval (http://localhost:5555/app/app.routes.js:16:4)
at eval (http://localhost:5555/app/app.routes.js:17:3)
at Object.eval (http://localhost:5555/app/main.js:7:20)
at eval (http://localhost:5555/app/main.js:28:4)
at eval (http://localhost:5555/app/main.js:29:3)
Evaluating http://localhost:5555/app/dashboard/tdr/tdr-list.component.js
Evaluating http://localhost:5555/app/dashboard/tdr/index.js
Evaluating http://localhost:5555/app/dashboard/dashboard.routes.js
Evaluating http://localhost:5555/app/dashboard/index.js
Evaluating http://localhost:5555/app/app.routes.js
Evaluating http://localhost:5555/app/main.js
Error loading http://localhost:5555/app/main.js

Not able to capture blur event

Is there any way to capture the blur event on ng2-completer component other than (blur) ?
I am able to capture focus event but not blur event.

Async remote service

I'd like to know your opinion regarding the the remote service.
I believe an async data service would be a better approach than a remote one.
The implementation to fetch and handle the data, probably, would be already done.

In my case, I had to come up with the solution:

this.dataService = this.completerService.local(this.searchData, 'name', 'name');

this.userFactory.loadAll().subscribe((data) => this.searchData.push(...data));

How can i access to the input value?

In case the searching text of the input doesn't match any result, how can I access to that value from the component?

According to the readme, there is this string : private searchStr: string;
but when I use console.log(this.searchStr), I just get undefined

import { Component } from '@angular/core';
import { CompleterService, CompleterData } from 'ng2-completer';

@Component({
  selector: 'my-component',
  template: `<h1>Search color</h1>
            <ng2-completer [(ngModel)]="searchStr" [dataService]="dataService" [minSearchLength]="0"></ng2-completer>`
})
export class MyComponent {

  private searchStr: string;
  private dataService: CompleterData;
  private searchData = [
    { color: 'red', value: '#f00' },
    { color: 'green', value: '#0f0' },
    { color: 'blue', value: '#00f' },
    { color: 'cyan', value: '#0ff' },
    { color: 'magenta', value: '#f0f' },
    { color: 'yellow', value: '#ff0' },
    { color: 'black', value: '#000' }
  ];

  constructor(private completerService: CompleterService) {
    this.dataService = completerService.local(this.searchData, 'color', 'color');
  }
}

Support for custom HTML and CSS

Currently the input box has a class of 'completer-input' specified, but I see no way to add my own css class to the input, like 'form-control' so it styles properly in bootstrap.

Any ideas?

material component error

Hello,
So i tried the following and i get an error with ng2-completer-md but not with ng2-completer-md in html.

                <ng2-completer-md [(ngModel)]="myData" [dataService]="dataRemote2"
                               [minSearchLength]="3" [placeholder]="'search country'"
                               [ngModelOptions]="{standalone: true}"
                               (selected)="onLocationSelected($event)"
                               [textSearching]="'Please wait...'">
                </ng2-completer-md>

/// as soon i change ng2-completer-md to ng2-completer it works...

                <p>Selected country: {{myData | json }}</p>
       private dataRemote2: RemoteData;
....
....
....
        this.dataRemote2 = completerService.remote(null, null, "formatted_address");
        this.dataRemote2.urlFormater(term => {
            return `https://maps.googleapis.com/maps/api/geocode/json?address=${term}`;
        });
        this.dataRemote2.dataField("results");

All suggestion boxes linked to the same dataService open when typing in one

Thank you for this wonderful helper!

I'm using an *ngFor and creating several ng2-completers all linked to the same dataService but using different ngModels. When editing one, the Searching... message only appears in the current field's list but once it's complete all the ng2-completer lists appear with the results instead of only the active one. I tried setting unique inputNames for all of them but the behavior continued.

Should I change my code to perhaps only instantiate a single ng2-completer when an item is clicked in preparation for editing? In that case, it'd be wonderful to be able to have the input element of the ng2-completer automatically focused (otherwise it also has to be clicked). Alternatively, is there a way to restrict the search results to just the active instance?

Access Data from Remote API With Auth Headers & User Input

I need a typeahead on my page that will access a remote service that returns a list of matching items. (what a typehead does). However, there are thousands of possible items that can be returned and I don't want to make the call to my service until the user has entered a minimum number of characters.

Once the minimum is reached, my service takes the user input and appends it to my get request to significantly reduce the number of items returned.

With the ng2-completer component it looks like I have to load every single potential item into my app when the page is initialized and I need to avoid that. I also need to be able to pass in authorization headers to my service and I can't see a way to do that with this component.

Is any of this possible using ng2-completer? It was with angucomplete-alt which is what I used to be using. There was an attribute called remote-api-handler that was tied to a method which could then make a request to my service and return only the data that matched my user input.

Example Local Data Structure

Hello, so i have country .json as following

{
  "BD": "Bangladesh",
  "BE": "Belgium",
  "BF": "Burkina Faso",
  "BG": "Bulgaria",
  "BA": "Bosnia and Herzegovina",
  "BB": "Barbados",
  "WF": "Wallis and Futuna",
  "BL": "Saint Barthelemy",
.....

How can i use this data for a selector. this.dataService = completerService.local(this.searchData, ??, ??);

Can not search with text unicode

Hello,

I have a problem with text search in unicode, I use VietNamese language and search with text as "đầm", it can not sent correct text to api.

Please help me!
Thank you!

completerService call from constructor

@oferh

I have a question do we need to make completerService call always from constructor?
For example, from the demo completerService is called from AppComponent Constructor(), Can i call the service from different method?

Reason is the remote url (or even if i use custom data) has some parameter other than the search parameter(from completer input) , the parameter will be at appComponent which can be changed.

Since I'm calling the service from constructor, I'm not able to pass the additional parameter which is part of appcomponent. Please advise.

Update Importing Architecture to Make Full Use of NgModule

I propose refactoring the exports of ng2-completer so that instead of using

@NgModule({
    ...
    declarations: [
        ...
        CompleterCmp
    ],
    providers: [
        ...
        COMPLETER_DATA_PROVIDERS,
        CompleterService
    ],
    ....
})

developers will be able to import it as a module like so:

@NgModule({
    imports: [
        ...
        Ng2CompleterModule
    ],
    ....
})

As per the modular architecture recommended in RC5

Apply class to child input for styling purposes

Is it possible to add a class to the child input that is generated inside of the ng2-completer directive? Obviously styling can be done without that but we have a project that will potentially use multiple bootstrap style themes and don't want to have to custom style the element for each theme.

npm download

Will you release your project to be downloaded using npm instead of cloning?

AOT support

Hello,
Does it support AOT, i tried to compile but i get the error Error: Unexpected value 'Ng2CompleterModule' imported by the module 'AppModule'

Use via Attribute

Opening the issue again #21 again, i'm still unable to use the autocomplete if i do like

<ion-input ng2-completer .....></ion-input>

Can you share an example how i would be able to do that with material design component?

Thanks

Override Remote http.get in remote search?

Hello,
Is there a way to override this.http.get in remote search? i actually want to use data decryptor instead of .map((res: Response) => res.json()) or the best bet is to fork the repo and change it there.

Thanks.

[Question] How can I use a bootstrap input field?

This project is very good, but all my application is created with inputs/forms of bootstrap 3.

How can I restore the css to use bootstrap? Also, how can I include this component into a form-group (bootstrap3)?

Thank you.

Bind selection to the object, not just to the search string.

Hey,

Is it possible to select the whole object and not just the string that identified it?

In the example searchStr is a string, so if I want to do something with the whole object that was selected, I need to go through the whole data provided to dataService and find which object was selected by filtering the whole list.

Unexpected value 'Ng2CompleterModule' imported by the module 'AppModule'

I'm trying to use your ng2-completer component inside of an ionic 2 project and I'm getting the following error.

`ngc error: Error: Unexpected value 'Ng2CompleterModule' imported by the module 'AppModule'
at C:\Users\Hyrum\Documents\ProjectDev\test\ionic-conference-app\node_modules@angular\compiler\bundles\compiler.umd.js:14109:37
at Array.forEach (native)
at CompileMetadataResolver.getNgModuleMetadata (C:\Users\Hyrum\Documents\ProjectDev\test\ionic-conference-app\node_modules@angular\compiler\bundles\compiler.umd.js:14094:46)
at C:\Users\Hyrum\Documents\ProjectDev\test\ionic-conference-app\node_modules@angular\compiler\bundles\compiler.umd.js:12936:58
at Array.forEach (native)
at OfflineCompiler.analyzeModules (C:\Users\Hyrum\Documents\ProjectDev\test\ionic-conference-app\node_modules@angular\compiler\bundles\compiler.umd.js:12935:21)
at CodeGenerator.codegen (C:\Users\Hyrum\Documents\ProjectDev\test\ionic-conference-app\node_modules@angular\compiler-cli\src\codegen.js:105:47)
at codegen (C:\Users\Hyrum\Documents\ProjectDev\test\ionic-conference-app\node_modules@angular\compiler-cli\src\main.js:7:81)
at Object.main (C:\Users\Hyrum\Documents\ProjectDev\test\ionic-conference-app\node_modules@angular\tsc-wrapped\src\main.js:30:16)
at Object. (C:\Users\Hyrum\Documents\ProjectDev\test\ionic-conference-app\node_modules@angular\compiler-cli\src\main.js:14:9)

[14:26:22] ngc error: Compilation failed

[14:26:22]
[14:26:22] bundle prod started ...
[14:26:22] Error: Could not resolve entry (.tmp/app/main.prod.js)
at C:\Users\Hyrum\Documents\ProjectDev\test\ionic-conference-app\node_modules\rollup\dist\rollup.js:8602:28
at process._tickCallback (node.js:369:9)
[14:26:22] sass started ...
[14:26:24] sass finished in 1.65 s
[14:26:24] minify started ...
[14:26:24] cleancss started ...
[14:26:24] uglifyjs started ...
[14:26:24] Error: ENOENT: no such file or directory, open 'C:\Users\Hyrum\Documents\ProjectDev\test\ionic-conference-app\www\build\main.js'
at Error (native)
at Object.fs.openSync (fs.js:549:18)
at Object.fs.readFileSync (fs.js:397:15)
at addFile (C:\Users\Hyrum\Documents\ProjectDev\test\ionic-conference-app\node_modules\uglify-js\tools\node.js:68:22)
at C:\Users\Hyrum\Documents\ProjectDev\test\ionic-conference-app\node_modules\uglify-js\tools\node.js:79:17
at Array.forEach (native)
at Object.exports.minify (C:\Users\Hyrum\Documents\ProjectDev\test\ionic-conference-app\node_modules\uglify-js\tools\node.js:77:26)
at runUglifyInternal (C:\Users\Hyrum\Documents\ProjectDev\test\ionic-conference-app\node_modules@ionic\app-scripts\dist\uglifyjs.js:34:19)
at runUglify (C:\Users\Hyrum\Documents\ProjectDev\test\ionic-conference-app\node_modules@ionic\app-scripts\dist\uglifyjs.js:23:28)
at Object.uglifyjs (C:\Users\Hyrum\Documents\ProjectDev\test\ionic-conference-app\node_modules@ionic\app-scripts\dist\uglifyjs.js:9:12)
[14:26:25] cleancss finished in 1.07 s
[14:26:25] minify finished in 1.07 s
[14:26:25] build prod finished in 6.66 s
`

I've been unsuccessful in getting it to work in my application so I cloned this sample ionic project and built it according to the instructions given on the front page.
run "npm install" from the project root.
Install the ionic CLI with "npm install -g ionic"
run the project in a browser with "ionic serve"

The project runs fine and everything in it works.

I then add the ng2-completer module using the instructions given here and when I try to run the project again I get the above error.

I've looked for quite a bit for a solution and found this similar issue.

Any help would be greatly appreciated

Limit the number of search results

Is there a way to restrict the number of output entries?
If Completer finds 100 entries, then it overlaps the whole page in the browser.

Update readme for rc5

Hi, you should update the readme with

import {CompleterCmp, CompleterService, COMPLETER_DATA_PROVIDERS} from 'ng2-completer';

@NgModule({
imports: [ ....],
declarations: [ CompleterCmp ],
providers: [ COMPLETER_DATA_PROVIDERS, CompleterService ]
],
bootstrap: [ ApplicationComponent ]
})

Or something similar, because directives and providers (in @component) will be removed in the next release of angular2 as explained here https://angular.io/docs/ts/latest/cookbook/rc4-to-rc5.html

component removed from the dom on backspace

Hi and thank you for an awesome, awesome component!
In case I've been missing something, in my app, the component is removed from the DOM when the last character is deleted
from the input field using the backspace key.
Is it to be expected and if yes, is there a way to prevent this behaviour? Otherwise, I'm happy to provide you with more info.

Regards,

Candide

Missing module problem ?

Hello I'm trying to install ng2-completer through npm.
Whenever I launch my app, I get this error :

node_modules/ng2-completer/bundles/src/ng2-completer.d.ts(1,30): error TS2307: Cannot find module './components/ng2-completer/completer-cmp'.

Is there something I overlooked ? I am running 1.2.0.

Thank you for your help !

making the field required?

So i wanted to make the field required, i tried adding formControlName="address" and in formControls address: ['', Validators.required], but it does not work.

Am i missing anything?

Question: How i can use post?

Questions:

  1. How i can use ajax post query with remote url?
  2. Is exits event on clear input ?
  3. How set value on input ?

for example - i have 3 dropdown for geo: Country/Region/City

When i select City - need set value for Country and Region
If i clean input Region - I do not want to the value sent to the server

No files

Hi When I install this module I dont have any files except package and readme.txt.

Can you check?

Using with mgechev/angular2-seed

I can't seem to get this to load using the mgechev/angular2-seed project.

Under paths I've added

 'ng2-completer': '${this.NPM_BASE}ng2-completer/bundles',

and packages section I added

 'ng2-completer': {
    main: 'ng2-completer.js',
    format: 'cjs'
  }

but I get the error that it can't find node_modules/ng2-completer/bundles.js so I tried setting the path to '${this.NPM_BASE}ng2-completer/bundles/ng2-completer.js' and I get the error

Module not already loaded loading "@angular/core" as       
http://localhost:5555/node_modules/@angular/core/bundles/core.umd.(…)`

Thanks for looking!

UPDATE

It seems to only error when I actually try to add the directives to a component.

import {
  CompleterCmp,
  CompleterService,
  CompleterData,
  COMPLETER_DATA_PROVIDERS} from 'ng2-completer';

@Component ({
  directives: [CompleterCmp],
  providers: [COMPLETER_DATA_PROVIDERS, CompleterService]
})

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.