Skip to content

Instantly share code, notes, and snippets.

@eneajaho
Last active September 28, 2022 12:46
Show Gist options
  • Save eneajaho/5e59754214db07383c4d2301bbdaf34d to your computer and use it in GitHub Desktop.
Save eneajaho/5e59754214db07383c4d2301bbdaf34d to your computer and use it in GitHub Desktop.
Angular component with pipe (user code)
@Pipe({ name: 'plusOne', standalone: true })
export class PlusOnePipe implements PipeTransform {
transform(value: number): number {
return value + 1;
}
}
@Component({
selector: "app-root",
template: `
<div>{{ count | plusOne }}</div>
<button (click)="count = count + 1">Increase</button>
`,
standalone: true,
imports: [PlusOnePipe],
})
export class AppComponent {
count = 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment