import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; @Component({ selector: 'rh-string-keyboard', templateUrl: './string-keyboard.component.html', styleUrls: ['./string-keyboard.component.less'] }) export class RhStringKeyboardComponent implements OnInit { // tslint:disable-next-line: variable-name private _currentValue = ''; @Input() get currentValue() { return this._currentValue; } set currentValue(data: string) { this._currentValue = data; this.currentValueChange.emit(data); } @Output() currentValueChange: EventEmitter = new EventEmitter(); @Output() submitRequest: EventEmitter = new EventEmitter(); @Input() isButtonVisible = true; constructor() { // } ngOnInit() { // } // 计算器 attacChar(char: string) { this.currentValue = this.currentValue.trim() + char; } clearLastChar() { if (this.currentValue.length >= 1) { this.currentValue = this.currentValue.slice(0, this.currentValue.length - 1); } } onsubmit($event: Event) { if ($event) { $event.preventDefault(); } this.submitRequest.emit(this.currentValue); } }