import { BaseInputComponent } from 'first-npm-package-nicule/forms';
import { ControlContainer, NgForm } from '@angular/forms';
import { Component } from '@angular/core';

@Component({
    templateUrl: 'select-field.component.html',
    styleUrls: ['../mat-field.scss', 'select-field.component.scss'],
    viewProviders: [{ provide: ControlContainer, useExisting: NgForm }]
})
export class SelectFieldComponent extends BaseInputComponent {

    get selectedValueKey(): string {
        return this.field.options
            .find(option => option.value === this.ngModel.control.value)
            .name;
    }
}
