I am using a strip down version of MDBootstrap(A) for material design on fields. In one field after pressing reset button, the value is pre-filled. But the animation of the label is not activated when that happens so the value and label is overlapping.
By the way this happens when the page is first loaded. It actually works when it is loaded with a value in, but doesn't work when I delete the value goes to invalid then I reset the the fields with the button. Value comes back but the activation of label for animation does not happen. May be it is CSS issue.
<div class="md-form form-group">
<input type="text"
id="portalName"
mdbActive
[ngClass]="{'invalid':(portal.errors && portal.touched) || (portal.errors && portal.dirty), 'valid':(!portal.errors && portal.touched) || (!portal.errors && portal.dirty)}"
class="form-control"
name="portalName"
[(ngModel)]="portalName.companyName"
#portal="ngModel"
[maxlength]="12"
required />
<label for="portalName">{{"CUSTOM_BRANDING.LABELS.BESPOKE_NAME" | translate }}</label>
<div *ngIf="portal.errors && (portal.dirty || portal.touched)"
class="message position-absolute">
<div [hidden]="!portal.errors.required" class="error-message" >
{{"CUSTOM_BRANDING.ERRORS.REQUIRED" | translate }}
</div>
<div [hidden]="!portal.errors.maxlength" class="error-message" >
{{"CUSTOM_BRANDING.ERRORS.MAX_LENGTH" | translate }}
</div>
</div>
</div>
I have to say I am pretty new with angular 2. I am trying to create something inside the component that when reset happens and value is filled in at least do a check on the field like setTouched or reset. Not sure what is best. I have this code in the component controlling the template
resetCustBrand = (): void => {
this.facade.resetBrandLogoAndName(this.facade.CommonNodeModel.SelectedNode.Id)
.subscribe({
complete: () => {
this.selectedNodeChanged(this.facade.CommonNodeModel.SelectedNode);
this.translator.getTranslationBaseOnKey("CUSTOM_BRANDING.TOASTER_RESET_BRANDING").subscribe((message: string) => {
const toasterMessage = message.split(',');
this.toaster.pop("success", toasterMessage[0], toasterMessage[1]);
});
},
error: () => this.translator.getTranslationBaseOnKey("CUSTOM_BRANDING.ERRORS.RESETING_BRANDING").subscribe((errorMessage: string) => this.notifyService.notifyUser(errorMessage))
});
}
I am hoping I may add something here to set the field again.