Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions apps/angular/9-wrap-function-pipe/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { Component } from '@angular/core';
import { WrapFunctionPipe } from './wrap-fn.pipe';

@Component({
selector: 'app-root',
imports: [WrapFunctionPipe],
template: `
@for (person of persons; track person.name) {
{{ showName(person.name, $index) }}
{{ isAllowed(person.age, $first) }}
{{ showName | wrapFn: person.name : $index }}
{{ isAllowed | wrapFn: person.age : $first }}
}
`,
})
Expand Down
15 changes: 15 additions & 0 deletions apps/angular/9-wrap-function-pipe/src/app/wrap-fn.pipe.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Pipe } from '@angular/core';

@Pipe({
name: 'wrapFn',
standalone: true,
pure: true,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this two flags are the default one.

Did you do it by yourself or did you use AI? just for my own information

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had some issues so I wanted to test things out and I added these flags in order to find a bug in my code :D. I use github copilot

})
export class WrapFunctionPipe {
transform<T extends (...args: any[]) => any>(
fn: T,
...args: Parameters<T>
): ReturnType<T> {
return fn(...args);
}
}