I have the current (& simplified) class :
export class NavigationItem {
constructor(
private router: Router
) {}
navigateTo() { this.router.navigate([this.id]); }
}
I would like not to have to inject myself the router everytime I declare a new instance of this class.
Is there a way of doing so ? I thought about something along the lines of
export class NavigationItem {
@Inject(forwardRef(() => Router))
private _router: Router;
constructor() {}
navigateTo() { this.router.navigate([this.id]); }
}
But it doesn't seem to work. Any idea ?