import { Component, EventEmitter, Output } from '@angular/core' import { Keys } from 'numeric-keyboard' const PasswordLayout = [ [ { key: Keys.ONE }, { key: Keys.TWO }, { key: Keys.THREE }, ], [ { key: Keys.FOUR }, { key: Keys.FIVE }, { key: Keys.SIX }, ], [ { key: Keys.SEVEN }, { key: Keys.EIGHT }, { key: Keys.NINE }, ], [ { key: Keys.BLANK }, { key: Keys.ZERO }, { key: Keys.DEL }, ], ] const PasswordTemplate = `

Conform password

` @Component({ selector: 'password', template: PasswordTemplate, styleUrls: [ './app.component.styl' ] }) export class Password { @Output() confirm = new EventEmitter() public PasswordLayout: any = PasswordLayout public password: string = '' press(key) { if (key === Keys.DEL) { this.password = this.password.slice(0, -1) } else { this.password = this.password + key if (this.password.length === 6) { setTimeout(() => this.confirm.emit(this.password), 100) } } } } const AppTemplate = `

Transfer to Arthur

Power by Numeric Keyboard

` @Component({ selector: '#app', template: AppTemplate, styleUrls: [ './app.component.styl' ] }) export class App { public amount: string | number = '' public shouldOpenPassword: boolean = false confirmAmount(e) { if (e) { e.preventDefault() } if (this.amount) { this.shouldOpenPassword = true } } confirmPassword(password) { this.shouldOpenPassword = false setTimeout(() => alert(`Amount: ${this.amount}\nPassword: ${password}`), 200) } }