1.0.14 • Published 2 years ago

indian-postal-codes v1.0.14

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Downloads/week

This library was generated with Angular CLI version 14.1.0.

Table of contents

  1. Getting Started
  2. Demo
  3. Installation
  4. Usage
  5. License

Getting Started

indian-postal-codes provides powered by Angular, so you don't need to include original JS components.

Demo

Indian Postal Codes components for Angular applications, demos and API documentation could be found here: http://thaaimozhikalvi.com/demo/pincode.

StackBlitz URL: https://stackblitz.com/indian-postal-codes

Installation

Install indian-postal-codes from npm:

npm install indian-postal-codes --save

Usage

Add wanted package to NgModule imports:

import {IndianPostalCodesModule} from "indian-postal-codes";

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

Add component to your page:

import {IndianPostalCodesService, PostOfficeDetails} from "indian-postal-codes";

@Component({...})

export class AppComponent {
    result: PostOfficeDetails[];
    constructor(private postalCodesService: IndianPostalCodesService) {}
}

Find By PinCodes:

this.postalCodesService.findByPinCode(pinCode).subscribe(data => {
      if (data[0].Status === 'Success') {
        this.result = data[0].PostOffice;
      } else if (data[0].Status === 'Error') {
        alert(data[0].Message);
        this.result = [];
      } else if (data[0].Status === '404') {
        alert(data[0].Message);
        this.result = [];
      }
    });

Find By Post Office:

this.postalCodesService.findByPostOfficeName(postOffice).subscribe(data => {
      if (data[0].Status === 'Success') {
        this.result = data[0].PostOffice;
      } else if (data[0].Status === 'Error') {
        alert(data[0].Message);
        this.result = [];
      } else if (data[0].Status === '404') {
        alert(data[0].Message);
        this.result = [];
      }
    });

Creator

GP DHANUSH

License

indian-postal-codes is MIT licensed.