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

ngx-autocomplete-api-custom

v0.0.0

Published

Angular material autocomplate component that featch data. Simply set an url to the config input and the component will generate an autocomplate component form the data that returns from the API

Downloads

4

Readme

Autocomplete using API

Angular material autocomplate component that featch data. Simply set an url to the config input and the component will generate an autocomplate component form the data that returns from the API

Installation

$ yarn add ngx-autocomplete-api

or

$ npm install ngx-autocomplete-api

Usage

Import NgxAutocompleteApiModule in your app:


import { NgModule } from '@angular/core';
import { HttpClientModule } from '@angular/common/http';
import { MatAutocompleteModule } from '@angular/material/autocomplete';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input';
import { NgxAutocompleteApiModule } from 'ngx-autocomplete-api';
 
@NgModule({
  imports: [
    HttpClientModule,
    MatAutocompleteModule,
    FormsModule,
    ReactiveFormsModule,
    MatFormFieldModule,
    MatInputModule,
    NgxAutocompleteApiModule,
    ]
})
export class AppModule {}

app.component

import { Component } from '@angular/core';
import { HttpRequestConfig } from 'ngx-autocomplete-api';

@Component({
  selector: 'app-root',
  template: `
      <ngx-autocomplete-api [httpRequestConfig]="config" [mapDataFunction]="mapFunction"></ngx-autocomplete-api>
  `,
  styles: []
})
export class AppComponent {

  value = 'Clear me';
  config: HttpRequestConfig = {
    method: 'GET',
    dataApi: 'https://demo.dataverse.org/api/search?q=<thisIsText>',
    fieldToDisplay: 'name',
    textInUrlToReplace: '<thisIsText>'
  };
  

  mapFunction = (data) => {
    return data.data.items
  }

}

Custom view for option

<ngx-autocomplete-api [httpRequestConfig]="config" [mapDataFunction]="mapFunction">
    <div *option="let option">
        {{option.name}}
     </div>
</ngx-autocomplete-api>
Properties

| Name | Description | | ------ | ------ | | @Input('httpRequestConfig') config: HttpRequestConfig | Configuration for the http request. | | @Input() mapDataFunction: (data: any) => any | Optinal. Map functoin for pipe the http request. | | @Input() formFieldAppearance: MatFormFieldAppearance = 'standard' | Angular form field tag appearance | | inputCtrl: FormControl = new FormControl('') | Form Control for the input | | dataObserver: Observable | observer for the data stream | | inputSubscriber: Subscription | subscriber for user text input | | dataApi: string;|Route for the HTTP request| |textToReplace: string = ''|Text inside to url need to be changed accurdenly to the user search| |httpMethod: 'GET' | 'POST' = 'GET'| Which http method to use| |fieldToDisplay: string;|Field name inside the return object to display in the autocomplate|

API reference for Angular Material autocomplete

Angular material autocomplete API.

| Name | Description | | ------ | ------ | | @Input() displayWith: ((value: any) => string) | Function that maps an option's control value to its display value in the trigger. | | @Input('class') classList: string string[]; | Takes classes set on the host mat-autocomplete element and applies them to the panel inside the overlay container to allow for easy styling. | | @Input() autoActiveFirstOption: boolean | Whether the first option should be highlighted when an autocomplete panel is opened. | | @Input() disableRipple: boolean | Whether ripples are disabled.| | @Input() panelWidth: string | number | Specify the width of the autocomplete panel. Can be any CSS sizing value, otherwise it will match the width of its host.| | @Input() panelWidth: string | Whether ripples are disabled.| | @Output() closed: EventEmitter | Event that is emitted when the autocomplete panel is closed.| | @Output() opened: EventEmitter | Event that is emitted when the autocomplete panel is opened.| | @Output() optionSelected: EventEmitter | Event that is emitted whenever an option from the list is selected.| | @Output() optionActivated: EventEmitter | Event that is emitted whenever an option from the list is selected.|