Giter Club home page Giter Club logo

angular-locale-currency-input's Introduction

Angular Locale Currency

This repos is creating a library for angular currency input and also it is showing how to use the library

Package is available here - https://www.npmjs.com/package/locale-currency-input

Installation - localeCurrencyInput

$ npm i locale-currency-input

Description

The directive can be used in html input to automatically change the input to locale currency.

  • Input in any locale currency convert to number inside the component. On focus the user will see to type in number and on focus out the user will see the number in currency format with the support of internalization format and currency symbol

  • The selector name of the directive is localeCurrencyInput

  • The directive consists of two inputs:

    • currencyCode (default value = 'USD')
    • allowNegative (default value = false)
  • For more details , the project is inside projects/locale-currency-input.

Demo

  • Demo Url: https://stackblitz.com/edit/angular-6m72i8

  • The following steps is required to use this directives:

    • The module need to import

      • import { LocaleCurrencyInputModule} from 'locale-currency-input';
    • Inside the view you need to call localeCurrencyInput and add input. Below is one of the example

      <input type="text" localeCurrencyInput [allowNegative]="false" [currencyCode]="'USD'" [value]="usAmount" (blur)="updateUSAmount($event)" />

    • Inside the component you can get the value by using event like blur or click or any other event. Below is one of the example updateUSAmount(event) { this.usAmount = event.target.value; }

    • In this demo, I've also used translation services to get the locale. If localeId is passed then the currency number format show based on the locale otherwise it get the localeId from browser language. You can also use chrome plugin to set the locale and test in different language. Here is the chrome plugin to switch the local- https://chrome.google.com/webstore/detail/locale-switcher/kngfjpghaokedippaapkfihdlmmlafcc

  • For more details, the demo is inside src.

Development server

Run ng serve for a dev server. Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.

Build

Run ng build to build the project. The build artifacts will be stored in the dist/ directory. Use the --prod flag for a production build.

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.