Files
print-calculator/frontend/src/app/shared/components/app-select/app-select.component.ts
Joe Küng debf153f58
All checks were successful
Build, Test and Deploy / test-backend (push) Successful in 22s
Build, Test and Deploy / build-and-push (push) Successful in 21s
Build, Test and Deploy / deploy (push) Successful in 5s
feat(web): update quality print advanced and base
2026-02-06 13:58:23 +01:00

41 lines
1.2 KiB
TypeScript

import { Component, input, output, forwardRef } from '@angular/core';
import { ControlValueAccessor, NG_VALUE_ACCESSOR, ReactiveFormsModule, FormsModule } from '@angular/forms';
import { CommonModule } from '@angular/common';
@Component({
selector: 'app-select',
standalone: true,
imports: [CommonModule, ReactiveFormsModule, FormsModule],
providers: [
{
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => AppSelectComponent),
multi: true
}
],
templateUrl: './app-select.component.html',
styleUrl: './app-select.component.scss'
})
export class AppSelectComponent implements ControlValueAccessor {
label = input<string>('');
id = input<string>('select-' + Math.random().toString(36).substr(2, 9));
options = input<{label: string, value: any}[]>([]);
error = input<string | null>(null);
value: any = '';
disabled = false;
onChange: any = () => {};
onTouched: any = () => {};
writeValue(obj: any): void { this.value = obj; }
registerOnChange(fn: any): void { this.onChange = fn; }
registerOnTouched(fn: any): void { this.onTouched = fn; }
setDisabledState(isDisabled: boolean): void { this.disabled = isDisabled; }
onModelChange(val: any) {
this.value = val;
this.onChange(val);
}
}