I am changing the Dependency Injection pattern we use so the team minimise the use of Typescript constructors. This avoids some recurring issues we get with people adding logic which should not be in constructors.
We can easily move from this pattern:
constructor(private readonly fb: FormBuilder) {}
to this one:
private readonly fb = inject(FormBuilder);
But we could not find a way to move the following out of the constructors
constructor(@Inject(MAT_DIALOG_DATA) public data: string ) {}
How could it be done?
You can use the new inject
function also to inject injection tokens.
i.e.
private readonly data: string = inject(MAT_DIALOG_DATA);