converter/src/app/converter-selector/converter-selector.componen...

34 lines
1.1 KiB
TypeScript

import {Component, Input, OnInit} from '@angular/core';
import {Step} from '../step';
import {Converter} from '../converter/converter';
import {ConverterRegistryService} from '../converter-registry.service';
import {TextInputFieldComponent} from '../text-input-field/text-input-field.component';
import {CommonModule} from '@angular/common';
@Component({
selector: 'app-converter-selector',
templateUrl: './converter-selector.component.html',
standalone: true,
styleUrls: ['./converter-selector.component.scss'],
imports: [CommonModule]
})
export class ConverterSelectorComponent implements OnInit {
@Input()
public step!: Step;
@Input()
textInput!: TextInputFieldComponent;
public converters: Converter[] = [];
constructor(private converterRegistryService: ConverterRegistryService) {
}
convert($event: any): void {
this.step.selectedConverter = this.converterRegistryService.getConverter($event.target.selectedOptions[0].id);
this.textInput.update(this.step);
}
ngOnInit() {
this.converters = this.converterRegistryService.getAllConverters();
}
}