@muzykantov/ngx-dadata
TypeScript icon, indicating that this package has built-in type declarations

0.2.4 • Public • Published

ngx-dadata

Angular 6+ DaData suggestion (подсказки) implementation

Getting Started

Demo

Demo is here demo

Working code for this demo at stackblitz example

Installation

Install via npm package manager

npm install @muzykantov/ngx-dadata --save

Usage

Import ngx-dadata module

import { HttpClientModule } from '@angular/common/http';
...
import { NgxDaDataModule } from '@muzykantov/ngx-dadata';

@NgModule({
  imports: [ HttpClientModule, NgxDaDataModule ]
})

Then in HTML

<ngx-da-data [config]="config" [(ngModel)]="currentAddress"></ngx-da-data>

or

<ngx-da-data formControlName="currentAddress" [config]="config"></ngx-da-data>

where

import { DaDataConfig } from '@muzykantov/ngx-dadata';

...

config: DaDataConfig = {
    apiKey: 'your_api_key',
    type: DaDataType.address
  };

also you may add additional options to constraint search (for example cities only):

import { DaDataConfig } from '@muzykantov/ngx-dadata';

...

config: DaDataConfig = {
    apiKey: 'your_api_key',
    type: DaDataType.address
    options: {
      from_bound: {value: "city"},
      to_bound: {value: "city"}
    }
  };

For ngModel to work, you must import FormsModule from @angular/forms, or for formControlName, you must import ReactiveFormsModule from @angular/forms

Package Sidebar

Install

npm i @muzykantov/ngx-dadata

Weekly Downloads

5

Version

0.2.4

License

MIT

Unpacked Size

309 kB

Total Files

39

Last publish

Collaborators

  • muzykantov