Input: Add condition if formControl to avoid undefined errors

This commit is contained in:
Konstantinos Triantafyllou 2022-06-01 14:12:18 +03:00
parent c9c1aff2ff
commit fd68a2cb10
1 changed files with 3 additions and 3 deletions

View File

@ -46,7 +46,7 @@ declare var UIkit;
@Component({
selector: '[dashboard-input], [input]',
template: `
<div [id]="id">
<div *ngIf="formControl" [id]="id">
<div class="input-wrapper" [class.disabled]="formControl.disabled" [class.opened]="opened"
[class.focused]="focused" [ngClass]="inputClass" [class.hint]="hint"
[class.active]="(formAsControl?.value || type === 'select' || formAsArray?.length > 0 || getLabel(formAsControl?.value)) && !focused"
@ -142,14 +142,14 @@ declare var UIkit;
</ul>
</div>
</div>
<span *ngIf="formControl.invalid && formControl.touched" class="uk-text-danger">
<span *ngIf="formControl?.invalid && formControl?.touched" class="uk-text-danger">
<span *ngIf="formControl.errors.error">{{formControl.errors.error}}</span>
<span *ngIf="type === 'URL' || type === 'logoURL'">Please provide a valid URL (e.g. https://example.com)</span>
</span>
<span class="uk-text-danger uk-text-small">
<ng-content select="[error]"></ng-content>
</span>
<span *ngIf="formControl.valid" class="uk-text-warning uk-text-small">
<span *ngIf="formControl?.valid" class="uk-text-warning uk-text-small">
<ng-content select="[warning]"></ng-content>
<span *ngIf="!secure">
<span class="uk-text-bold">Note:</span> Prefer urls like "<span class="uk-text-bold">https://</span>example.com/my-secure-image.png"