1.0.12 • Published 4 years ago

@mcorg/ion-currencymask v1.0.12

Weekly downloads
4
License
MIT
Repository
github
Last release
4 years ago

Ionic CurrencyMask

Installation

To install ,ion-currencymask run:

$ npm install @mcorg/ion-currencymask --save

Consuming your library

and then from your Angular AppModule:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';

import { HomePage } from '../pages/home/home';

// Import the library
import { IonCurrencyMaskModule } from '@mcorg/ion-currencymask';

@NgModule({
  declarations: [
    HomePage
  ],
  imports: [
    BrowserModule,
    IonicModule,
    // Import the module
    IonCurrencyMaskModule
  ],
  providers: [],
  bootstrap: [IonicApp]
})
export class AppModule { }

Once your library is imported, you can use its components in your Ionic application: This exemple used on code of showed in demo above

<!-- You can now use your library component in home.html -->
<ion-content padding>
  <p>
    The demo of the ion-currency-mask working in Reactive Forms
  </p>
  <form [formGroup]="formTest" (ngSubmit)="onSubmit()" >
    <ion-list>
      <!--the selector ion-currency-mask already has an ion-item themselves-->
      <ion-currency-mask
        placeholder="Insira o valor aqui"
        label="Valor R$"
        formControlName="maskMoney">
      </ion-currency-mask>
      <ion-item>
        <p>{{formTest.value | json}}</p>
      </ion-item>
    </ion-list>
  </form>
</ion-content>

In controller page

// ... Hidden unnecessary code
export class HomePage {

  public formTest: FormGroup;

  constructor(public navCtrl: NavController, private formBuilder: FormBuilder) {
    this.formTest = formBuilder.group({
      maskMoney: ['', Validators.required]
    });
  }
  // ... Hidden unnecessary code
}

Parameters to selector ion-currency-mask

ParameterTypeDescription
placeholderstringa value to placeholder of ion-input
labelstringa value to ion-label
typeLabelstringa type to ion-label. Values: stacked - fixed - floating . More info: Ionic Doc - Label
clearInputbooleantrue to add clearInput on ion-input. Default: false without clearInput . More info: Ionic Doc - Input
lastChildbooleanif the ion-currency-mask is the last of ion-list send true, Default: false
disabledbooleantrue to disabled the input. Default: false
noDecimalsbooleantrue to disable decimals. Default: false
reversebooleantrue to reverse decimals and thousands symbols ('.' => ','). Default: false

To do?

Feel free to make your pull request, chip in to suggestion or report issues.

Thanks

We used the core code made by Marlos Irapuan inspired on http://jsbin.com/heqeduyi/1/edit?html,output and we made some improvement to separate it into pieces of thousands. More info see: MaskMoney no Ionic 2

License

MIT © Mauro Cendón

Based on Lucas Correa original plugin

1.0.12

4 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago