Hello,
You can find tutorial/example here: https://www.inversionofcontrol.co.uk/injection-tokens-in-angular/
So it's something along the lines of:
export const ROUTER_SCROLL_SERVICE = new InjectionToken<string>('RouterScrollService');
Then in your module, you add it to the providers array like this:
@NgModule({
...
providers: [
{
provide: ROUTER_SCROLL_SERVICE,
useClass: RouterScrollServiceImpl
}
]
...
})
export class AppModule { }
The benefit of this approach is that you can inject the interface (thanks to the injection token) in your components instead of the implementation, meaning that you can easily mock out that dependency for tests.