Skip to content

Instantly share code, notes, and snippets.

@space11
Last active October 16, 2023 16:07
Show Gist options
  • Save space11/27e5fee669e8802f1421e4e83940f42c to your computer and use it in GitHub Desktop.
Save space11/27e5fee669e8802f1421e4e83940f42c to your computer and use it in GitHub Desktop.
Angular pipe that logs to the console template variable.
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);
}
}
<!-- Usage -->
{{ variable | log }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment