To improve your code quality, it is suggested to avoid direct access to the document
object and instead inject its custom provider from @angular/common
.
import { DOCUMENT } from '@angular/common';
Then, you can inject it in your constructor like this:
constructor(@Inject(DOCUMENT) private document: Document) {}
This way, you can easily mock the document object and set properties such as URL
or any other property as required. This approach is similar to injecting other services into your components or services.