import { Component, Input, OnInit } from '@angular/core'; import { AbstractControl } from '@angular/forms'; import { JsonSchemaFormService } from '../json-schema-form.service'; @Component({ // tslint:disable-next-line:component-selector selector: 'number-widget', template: `
`, }) export class NumberComponent implements OnInit { formControl: AbstractControl; controlName: string; controlValue: any; controlDisabled = false; boundControl = false; options: any; allowNegative = true; allowDecimal = true; allowExponents = false; lastValidNumber = ''; @Input() layoutNode: any; @Input() layoutIndex: number[]; @Input() dataIndex: number[]; constructor( private jsf: JsonSchemaFormService ) { } ngOnInit() { this.options = this.layoutNode.options || {}; this.jsf.initializeControl(this); if (this.layoutNode.dataType === 'integer') { this.allowDecimal = false; } } updateValue(event) { this.jsf.updateValue(this, event.target.value); } }