
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
ng2-input-autocomplete
Advanced tools
Angular2 input autocomplete
To install this library, run:
$ npm install ng2-input-autocomplete --save
and then from your Angular AppModule
:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
// Import your library
import { AutocompleteModule } from 'ng2-input-autocomplete';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
AutocompleteModule.forRoot()
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
Once your library is imported, you can use its components and directives:
Three input elements: config, items, ngModel
config supports two properties: placeholder and sourceField which is used to search. Two optional properties: class for customized css style and max for the max number of items.
Two output events: selectEvent (when a item is selected) and inputChangedEvent (when users input)
<!-- You can now use your library component in app.component.html -->
<h1>
String
</h1>
<input autocomplete [items]=["a", "ab"]></input>
<h2>Objects:</h2>
<div>
<input autocomplete [config]="config2" [items]="items2"
(inputChangedEvent)="onInputChangedEvent($event)"
(selectEvent)="onSelect($event)">
</div>
<h2>Wiki:</h2>
<div>
<input autocomplete [items]="wikiItems"
(inputChangedEvent)="search($event)"
(selectEvent)="onSelect($event)">
</div>
in styles.css
.test li.active {
width: 100%;
background-color: red!important;
}
.test li {
color: blue;
}
export class AppComponent {
selectedItem: any = '';
inputChanged: any = '';
wikiItems: any[] = [];
items2: any[] = [{id: 0, payload: {label: 'Tom'}},
{id: 1, payload: {label: 'John'}},
{id: 2, payload: {label: 'Lisa'}},
{id: 3, payload: {label: 'Js'}},
{id: 4, payload: {label: 'Java'}},
{id: 5, payload: {label: 'c'}},
{id: 6, payload: {label: 'vc'}}
];
config2: any = {'class': 'test', 'max': 2, 'placeholder': 'test', 'sourceField': ['payload', 'label']};
constructor(private service: WikipediaService) {}
onSelect(item: any) {
this.selectedItem = item;
}
onInputChangedEvent(val: string) {
this.inputChanged = val;
}
search (term: string) {
this.service.search(term).subscribe(e => this.wikiItems = e, error => console.log(error));
}
}
$ npm run test
MIT © liuy97
FAQs
Angular input auto complete
The npm package ng2-input-autocomplete receives a total of 297 weekly downloads. As such, ng2-input-autocomplete popularity was classified as not popular.
We found that ng2-input-autocomplete demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.