So, I was working on creating a custom MatTableDataSource. The Goal was to use custom filter/sorting and to directly integrated** with a custom class.** And I ran into a problem : I needed to call a function from one of my service. I found multiples solutions to this : One of them was to make the function "static". Which make sense for sorting/filtering. You have pure, without dependancy, functions. The other was to inject the service into the models by exporting an Injector from app.module.ts And this is where I started thinking about it. It feel like it's not a good solution, you don't want to create multiple class with injection. But on the other side What if the filtering function have dependancy to others functions in the app ? What if, for some reasons, we need API call ? In theses situations, how should i proceed ? Or How should I access the instance of my service ? Continue reading...