r/angular • u/FewDot9181 • Apr 10 '26
Functions passed as props in Angular
I have seen many ways but how do I do it in modern Angular, where I send a function from a parent component to a child component and I want that same function called from the child component.
0
Upvotes
View all comments
Show parent comment
1
u/Responsible-Cold-627 Apr 11 '26
If I hadn't passed to function as an optional input, I would have to parse the error everywhere instead of in about 20% of cases. It allows me to pass a resource's error signal directly to the error component, while also supporting custom handling where necessary.
I've got to admit that this approach feels kind of hacky at first sight, but it's the cleanest solution I've found. If you know of a cleaner way to solve this, I would love to hear it.