Last active
April 12, 2024 07:58
-
-
Save konstantindenerz/1569cce6a49deb2383fe863b0aa826e8 to your computer and use it in GitHub Desktop.
Angular - NullTo-Pipe ✨
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Pipe({ | |
name: 'nullTo', | |
standalone: true | |
}) | |
export class NullToPipe implements PipeTransform { | |
transform<T>(value: T | null, defaultValue: T): T { | |
return value === null ? defaultValue : value; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment