Skip to content

Instantly share code, notes, and snippets.

View envynoiz's full-sized avatar

Jorge Palomo envynoiz

View GitHub Profile
@envynoiz
envynoiz / mat-form-field-readonly.directive.ts
Last active March 23, 2025 18:54
MatFormField Readonly Directive
import { BooleanInput, coerceBooleanProperty } from '@angular/cdk/coercion';
import { afterRenderEffect, AfterViewInit, DestroyRef, Directive, inject, input } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { MatFormField } from '@angular/material/form-field';
import { MatInput } from '@angular/material/input';
import { fromEvent, filter } from 'rxjs';
@Directive({
selector: 'mat-form-field[readonlyField]'
})
@envynoiz
envynoiz / ecm6_exception.js
Last active June 11, 2018 02:16
Creating a custom exception using ECMAScript 6
class CustomException extends Error {
constructor(message) {
super(message);
this.name = this.constructor.name;
if ('function' === typeof Error.captureStackTrace) {
Error.captureStackTrace(this, this.constructor);
} else {
this.stack = (new Error(message)).stack;
}
}