Last active
October 16, 2023 16:07
-
-
Save space11/27e5fee669e8802f1421e4e83940f42c to your computer and use it in GitHub Desktop.
Angular pipe that logs to the console template variable.
This file contains hidden or 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
| import { Pipe, PipeTransform } from '@angular/core'; | |
| /** | |
| * Log pipe is used for debugging purposes allows quickly log to the console a template value. | |
| * | |
| * @example | |
| * <!-- Log value to a console. --> | |
| * <div> | |
| * {{ foo.value | log }} | |
| * </div> | |
| */ | |
| @Pipe({ | |
| name: 'log' | |
| }) | |
| export class LogPipe implements PipeTransform { | |
| transform(value: unknown): void { | |
| console.log(value); | |
| } | |
| } |
This file contains hidden or 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
| <!-- Usage --> | |
| {{ variable | log }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment