refactor: Das req-form-field-Komponente wurde entfernt.
This commit is contained in:
parent
9dea7a1198
commit
35cca9aef0
@ -1,23 +0,0 @@
|
|||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { ReqFormFieldComponent } from './req-form-field.component';
|
|
||||||
|
|
||||||
describe('ReqFormFieldComponent', () => {
|
|
||||||
let component: ReqFormFieldComponent;
|
|
||||||
let fixture: ComponentFixture<ReqFormFieldComponent>;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
await TestBed.configureTestingModule({
|
|
||||||
imports: [ReqFormFieldComponent]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
|
|
||||||
fixture = TestBed.createComponent(ReqFormFieldComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@ -1,41 +0,0 @@
|
|||||||
import { Component, signal } from '@angular/core';
|
|
||||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
||||||
import { FormControl, FormsModule, ReactiveFormsModule, Validators } from '@angular/forms';
|
|
||||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
||||||
import { MatInputModule } from '@angular/material/input';
|
|
||||||
import { merge } from 'rxjs';
|
|
||||||
import { MatIconModule } from '@angular/material/icon';
|
|
||||||
import { MatButtonModule } from '@angular/material/button';
|
|
||||||
import { CommonModule } from '@angular/common';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-req-form-field',
|
|
||||||
standalone: true,
|
|
||||||
imports: [MatFormFieldModule, MatInputModule, FormsModule, ReactiveFormsModule, MatIconModule, MatButtonModule, CommonModule],
|
|
||||||
templateUrl: './req-form-field.component.html',
|
|
||||||
styleUrl: './req-form-field.component.scss'
|
|
||||||
})
|
|
||||||
export class ReqFormFieldComponent {
|
|
||||||
readonly formControl = new FormControl('', [Validators.required, Validators.email]);
|
|
||||||
|
|
||||||
errorMessage = signal('');
|
|
||||||
|
|
||||||
public readonly formFieldBSClass: string = "col d-flex justify-content-center mx-1 my-2"
|
|
||||||
public readonly buttonBSClass: string = "d-flex justify-content-center mx-1 my-2"
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
merge(this.formControl.statusChanges, this.formControl.valueChanges)
|
|
||||||
.pipe(takeUntilDestroyed())
|
|
||||||
.subscribe(() => this.updateErrorMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
updateErrorMessage() {
|
|
||||||
if (this.formControl.hasError('required')) {
|
|
||||||
this.errorMessage.set('You must enter a value');
|
|
||||||
} else if (this.formControl.hasError('email')) {
|
|
||||||
this.errorMessage.set('Not a valid email');
|
|
||||||
} else {
|
|
||||||
this.errorMessage.set('');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user