My goal is to develop a RouterUtilities class that extends Angular's Router. Despite the app running and compiling smoothly, when I run ng build --prod
, it throws an error message like this:
ERROR in : Can't resolve all parameters for RouterUtilities in .../utils/router/router-utilities.ts: (?, [object Object], [object Object], [object Object], [object Object], [object Object],
[object Object], ?).
router-utilities.ts
import { Compiler, Injectable, Injector, NgModuleFactoryLoader, Type } from '@angular/core';
import { Location } from '@angular/common';
import { Router, UrlSerializer, ChildrenOutletContexts, Routes } from '@angular/router';
import { formatPattern } from 'url-matcher';
import { Dictionary } from '../../../shared/interfaces/common.interface';
@Injectable()
export class RouterUtilities extends Router {
constructor(rootComponentType: Type<any> | null,
urlSerializer: UrlSerializer,
rootContexts: ChildrenOutletContexts,
location: Location,
injector: Injector,
loader: NgModuleFactoryLoader,
compiler: Compiler,
config: Routes) {
super(rootComponentType, urlSerializer, rootContexts, location, injector, loader, compiler, config);
}
static getAbsoluteRoute(routePath: string, params: Dictionary<string> = {}): string {
return 'something';
}
}
Do you have any insights on why this error occurs?
- I've added RouterUtilities to the module's providers.
- I haven't injected this service into any component or service yet.
- The error persists even though the service hasn't been utilized.