import { AbstractControl } from '@angular/forms'; import { buildTitleMap, isArray } from '../shared'; import { Component, Input, OnInit } from '@angular/core'; import { JsonSchemaFormService } from '../json-schema-form.service'; @Component({ // tslint:disable-next-line:component-selector selector: 'select-widget', template: `
`, }) export class SelectComponent implements OnInit { formControl: AbstractControl; controlName: string; controlValue: any; controlDisabled = false; boundControl = false; options: any; selectList: any[] = []; isArray = isArray; @Input() layoutNode: any; @Input() layoutIndex: number[]; @Input() dataIndex: number[]; constructor( private jsf: JsonSchemaFormService ) { } ngOnInit() { this.options = this.layoutNode.options || {}; this.selectList = buildTitleMap( this.options.titleMap || this.options.enumNames, this.options.enum, !!this.options.required, !!this.options.flatList ); this.jsf.initializeControl(this); } updateValue(event) { this.jsf.updateValue(this, event.target.value); } }