Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9920587
commit 860a430
Showing
4 changed files
with
18 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 4 additions & 11 deletions
15
apps/dsp-app/src/app/project/common-input/common-input.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,22 @@ | ||
import { Component, Input } from '@angular/core'; | ||
import { FormControl, FormGroup } from '@angular/forms'; | ||
import { FormControl } from '@angular/forms'; | ||
|
||
@Component({ | ||
selector: 'app-common-input', | ||
template: ` | ||
<mat-form-field style="width: 100%"> | ||
<mat-icon matIconPrefix *ngIf="prefixIcon">{{ prefixIcon }}</mat-icon> | ||
<input matInput [placeholder]="placeholder" [formControl]="formControl" /> | ||
<mat-error *ngIf="formControl.errors as errors"> | ||
<input matInput [placeholder]="placeholder" [formControl]="control" /> | ||
<mat-error *ngIf="control.errors as errors"> | ||
{{ errors | humanReadableError: validatorErrors }} | ||
</mat-error> | ||
</mat-form-field> | ||
`, | ||
styles: [':host { display: block;}'], | ||
}) | ||
export class CommonInputComponent { | ||
@Input() formGroup: FormGroup; | ||
@Input() controlName: string; | ||
@Input() control: FormControl<string>; | ||
@Input() placeholder: string; | ||
@Input() prefixIcon: string | null = null; | ||
@Input() validatorErrors: { errorKey: string; message: string }[] | null = null; | ||
|
||
get formControl() { | ||
return this.formGroup.controls[this.controlName] as FormControl; | ||
} | ||
|
||
protected readonly FormGroup = FormGroup; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters