All Projects → AlexMiniApps → angular-code-input

AlexMiniApps / angular-code-input

Licence: MIT license
Code (number/chars/otp/password) input component for angular 7, 8, 9, 10, 11, 12+ projects including Ionic 4, 5 +

Programming Languages

typescript
32286 projects
SCSS
7915 projects
javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to angular-code-input

angularx-qrcode-sample-app
Angular5/6/7/8/9/10+ sample apps with working implementations of angularx-qrcode
Stars: ✭ 15 (-86.61%)
Mutual labels:  angular7, angular8, angular9
angular-progress-bar
This component allow you to easy incorporate progress-bar to angular/ionic project, providing binding and color options
Stars: ✭ 26 (-76.79%)
Mutual labels:  ionic, angular7, angular8
Angular-Movies
Angular Movies | TV Shows is a simple web app that consumes The Movie DB API - Angular 13 + Material Angular
Stars: ✭ 35 (-68.75%)
Mutual labels:  angular7, angular8
Ng Select
⭐ Native angular select component
Stars: ✭ 2,781 (+2383.04%)
Mutual labels:  angular7, angular8
ngx-ion-simple-mask
Input mask for Angular/Ionic
Stars: ✭ 21 (-81.25%)
Mutual labels:  ionic, angular7
angular-8-boilerplate
Angular 8 Boilerplate with bootstrap
Stars: ✭ 23 (-79.46%)
Mutual labels:  angular7, angular8
angular-material8-custom-theme
Angular Material 8 Custom Theme - Learn to create Angular Material 8 custom theme from scratch in less than 5 minutes in an Angular 8 project.
Stars: ✭ 16 (-85.71%)
Mutual labels:  angular7, angular8
ionic4-angular8-crud-mobileapps-example
Ionic 4 Angular 8 Tutorial: Learn to Build CRUD Mobile Apps
Stars: ✭ 20 (-82.14%)
Mutual labels:  ionic, angular8
GPS-Mobile-Tracking-App
Angular 9.0 HTML Bootstrap NodeJS and MYSQL App - Store GPS Mobile Browser Location
Stars: ✭ 32 (-71.43%)
Mutual labels:  angular7, angular8
ionic4-angular7-httpinterceptor-example
Ionic 4 and Angular 7 Tutorial: HTTP Interceptor Example
Stars: ✭ 15 (-86.61%)
Mutual labels:  ionic, angular7
ionic4-image-crop-upload
Ionic 4, Angular 7 and Cordova Crop and Upload Image
Stars: ✭ 16 (-85.71%)
Mutual labels:  ionic, angular7
ionic4-angular7-example
Ionic 4, Angular 7 and Cordova Tutorial: Build CRUD Mobile Apps
Stars: ✭ 57 (-49.11%)
Mutual labels:  ionic, angular7
ng-logger
Angular logger service
Stars: ✭ 65 (-41.96%)
Mutual labels:  angular8, angular9
vue-pincode-input
Great pincode input component
Stars: ✭ 128 (+14.29%)
Mutual labels:  input, pincode
Ng-Prime
Angular + PrimeNg
Stars: ✭ 88 (-21.43%)
Mutual labels:  angular7, angular8
laravel-otp
A laravel package to protect your routes with one time passwords (otp)
Stars: ✭ 147 (+31.25%)
Mutual labels:  otp
ionic-app-with-aws-cognito
Angular 4, Ionic 3, and AWS (Amazon) Cognito User Pools. Authentication out of the box.
Stars: ✭ 62 (-44.64%)
Mutual labels:  ionic
sharebook-mobile
Projeto mobile híbrido de código livre para o app Sharebook.
Stars: ✭ 22 (-80.36%)
Mutual labels:  ionic
cordova-set-version
CLI and JavaScript API for setting the version in Apache Cordova config.xml
Stars: ✭ 19 (-83.04%)
Mutual labels:  ionic
file-upload-with-preview
🖼 Simple file-upload utility that shows a preview of the uploaded image. Written in TypeScript. No dependencies. Works well with or without a framework.
Stars: ✭ 406 (+262.5%)
Mutual labels:  input

Code/pincode input component for angular

Robust and tested code (number/chars) input component for Angular 7 - 12+ projects.
Ionic 4, 5 + is supported, can be used in iOS and Android.
Clipboard events are supported.

Star Star it to inspire us to build the best component! Star

Preview

Supported platforms

Angular 7, 8, 9, 10, 11, 12 +
Ionic 4, 5 +
Mobile browsers and WebViews on: Android and iOS
Desktop browsers: Chrome, Firefox, Safari, Edge v.79 +
Other browsers: Edge v.41 - 44 (without code hidden feature)

Installation

$ npm install --save angular-code-input

Usage

Import CodeInputModule in your app module or page module:

import { CodeInputModule } from 'angular-code-input';

@NgModule({
  imports: [
    // ...
    CodeInputModule
  ]
})

It is possible to configure the component across the app using the root config. In such case the import will look as follows:

import { CodeInputModule } from 'angular-code-input';

@NgModule({
  imports: [
    // ...
    CodeInputModule.forRoot({
      codeLength: 6,
      isCharsCode: true,
      code: 'abcdef'
    }),
  ]
})

Include the component on page template HTML:

  <code-input [isCodeHidden]="true"
              [codeLength]="5"
              (codeChanged)="onCodeChanged($event)"
              (codeCompleted)="onCodeCompleted($event)">
  </code-input>

Inside a page script:

  // this called every time when user changed the code
  onCodeChanged(code: string) {
  }

  // this called only if user entered full code
  onCodeCompleted(code: string) {
  }

Configuration

View

It is possible to configure the component via CSS vars
or using ::ng-deep (deprecated) angular CSS selector ::ng-deep

CSS vars:

CSS Var Description
--text-security-type: disc; Text presentation type when the isCodeHidden is enabled
--item-spacing: 4px; Horizontal space between input items
--item-height: 4.375em; Height of input items
--item-border: 1px solid #dddddd; Border of input item for an empty value
--item-border-bottom: 1px solid #dddddd; Bottom border of input item for an empty value
--item-border-has-value: 1px solid #dddddd; Border of input item with a value
--item-border-bottom-has-value: 1px solid #dddddd; Bottom border of input item with a value
--item-border-focused: 1px solid #dddddd; Border of input item when focused
--item-border-bottom-focused: 1px solid #dddddd; Bottom border of input item when focused
--item-shadow-focused: 0px 1px 5px rgba(221, 221, 221, 1); Shadow of input item when focused
--item-border-radius: 5px; Border radius of input item
--item-background: transparent; Input item background
--color: #171516; Text color of input items

Example with only bottom borders:

/* inside page styles*/
...
  code-input {
    --item-spacing: 10px;
    --item-height: 3em;
    --item-border: none;
    --item-border-bottom: 2px solid #dddddd;
    --item-border-has-value: none;
    --item-border-bottom-has-value: 2px solid #888888;
    --item-border-focused: none;
    --item-border-bottom-focused: 2px solid #809070;
    --item-shadow-focused: none;
    --item-border-radius: 0px;
  }
...

Component options

Property Type Default Description
codeLength number 4 Length of input code
inputType string tel Type of the input DOM elements like <input [type]="inputType"/> default 'tel'
isCodeHidden boolean false When true inputted code chars will be shown as asterisks (points)
isCharsCode boolean false When true inputted code can contain any char and not only digits from 0 to 9. If the input parameter code contains non digits chars and isCharsCode is false the value will be ignored
isPrevFocusableAfterClearing boolean true When true after the input value deletion the caret will be moved to the previous input immediately. If false then after the input value deletion the caret will stay on the current input and be moved to the previous input only if the current input is empty
isFocusingOnLastByClickIfFilled boolean false When true and the code is filled then the focus will be moved to the last input element when clicked
initialFocusField number - The index of the input box for initial focusing. When the component will appear the focus will be placed on the input with this index.
Note: If you need to dynamically hide the component it is needed to use *ngIf directive instead of the [hidden] attribute
code string / number - The input code value for the component. If the parameter contains non digits chars and isCharsCode is false the value will be ignored
disabled boolean false When true then the component will not handle user actions, like in regular html input element with the disabled attribute
autocapitalize string - The autocapitalize attribute is an enumerated attribute that controls whether and how text input is automatically capitalized as it is entered/edited by the user

Events

Event Description
codeChanged Will be called every time when a user changed the code
codeCompleted Will be called only if a user entered full code

Methods

For calling the component's methods it is required to access the component inside the template or page script. It can be reached as follows.

Inside the page template HTML add a template ref:

  <code-input
        ...
        #codeInput
        ...
>
</code-input>

Inside a page script attach the component:

...
// adding to the imports
import {CodeInputComponent} from 'angular-code-input';
...
// adding to the page props
@ViewChild('codeInput') codeInput !: CodeInputComponent;
...
// calling the component's methods somewhere in the page.
// IMPORTANT: it will be accessible only after the view initialization!
this.codeInput.reset();
Method Description
focusOnField(index: number): void Focuses the input caret on the input box with the passed index
reset(isChangesEmitting = false): void

Resets the component values in the following way:

if the code option is supplied then the value will be reset to the code option value. If the code option is not supplied then the component will be reset to empty values.

if the initialFocusField option is supplied then the caret will be focused in that filed after reset.

if the isChangesEmitting param is passed then changes will be emitted

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].