Skip to content

Instantly share code, notes, and snippets.

View wh0th3h3llam1's full-sized avatar

Aarsh wh0th3h3llam1

  • San Jose, CA
  • 01:20 (UTC -07:00)
View GitHub Profile
@wh0th3h3llam1
wh0th3h3llam1 / error.service.ts
Last active May 14, 2022 06:54
Error Service to render form errrors
import { HttpErrorResponse } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { FormGroup } from '@angular/forms';
import { Router } from '@angular/router';
import { NzMessageService } from 'ng-zorro-antd/message';
@Injectable({
providedIn: 'root'
})
export class ErrorService {
@wh0th3h3llam1
wh0th3h3llam1 / non_fields_errors-form.component.html
Last active May 7, 2022 21:31
Render `non_field_errors` in Angular Ant Design
...
<nz-alert nzType="error" [nzMessage]="nonFieldErrors" *ngIf="non_field_errors.length > 0" nzShowIcon>
<ng-template #nonFieldErrors>
<nz-list>
<nz-list-item *ngFor="let error of non_field_errors">{{ error }}</nz-list-item>
</nz-list>
</ng-template>
</nz-alert>
...
@wh0th3h3llam1
wh0th3h3llam1 / common.interface.ts
Created November 14, 2022 19:34
Form & Common Service to get Dirty Controls in Angular along with a custom field mapping (date -> string)
export interface IDirtyControl {
field: string,
type: string,
convertTo: string,
}