Skip to main content

Posts

Showing posts from 2020

Blog Moved!

Not that I'm getting a lot of visitors to this site, but still having been around a few years and getting more than a couple of visitors a day, I feel compelled to make this announcement. So here goes. I have moved this blog to my company blog @  https://www.smallpearl.com/blog/ . I'll also be releasing the hari.xyz domain in due course.

Reflecting server errors in Angular form validation

Here's some sample code that shows how to display server validation errors sent by a django-restframework REST server. <form [formGroup]='form' (ngSubmit)="doChangePassword()"> <ion-item> <ion-label>{{ 'CURRENT_PASSWORD' | translate }}</ion-label> <ion-input formControlName="old_password" type="password"></ion-input> </ion-item> <ion-item class="ion-text-wrap ion-no-lines" *ngIf="form.controls.old_password.errors?.required && form.controls.old_password.dirty && form.controls.old_password.touched"> <ion-label color='danger' class="ion-no-margin" stacked>{{ 'FIELD_IS_REQUIRED' | translate }}</ion-label> </ion-item> <ion-item class="ion-no-lines" *ngFor="let errorMsg of form.controls.old_password.errors?.serverErrors"> <ion-label co...