I am trying to retrieve a data present in the url in my APP_INITIALIZER
app.module.ts
export function init(config: ConfigService, router: Router) {
r
config-service.ts can be rewritten as below.
@Injectable()
export class ConfigService
constructor(private injector: Injector){}
load(): Promise<any> {
const router = this.injector.get(Router);
console.log('current url : ' + router.url);
return new Promise(((resolve, reject) => resolve()));
}
}
No need to inject Router as a dependency in app.module.ts.
What I was trying to do isn't feasible since the APP_INITIALIZER happens before the router init. https://medium.com/hackernoon/hook-into-angular-initialization-process-add41a6b7e