I want to override a service from an other module, but i got the error "is not a function"
In my component (module 1) i inject the servie
public constructor(private chartProgressService: ChartProgressService) {
}
In module 2 i override the servive in providers
providers: [
{
provide: Configuration,
useClass: AppConfiguration,
},
{
provide: ChartProgressService,
useValue: MyChartProgressService
},
{
provide: LOCALE_ID,
useValue: 'de-DE',
}
],
and this is MyChartProgressService
import {Injectable} from '@angular/core';
@Injectable()
export class InnogyChartProgressService {
public getUnit(): string {
return '';
}
public getValue(currentValue: number, maxValue: number): number {
return currentValue;
}
}
The call this.chartProgressService.getValue() in my component returns the error
HeaderComponent.html:11 ERROR TypeError: this.chartProgressService.getUnit is not a function
at ChartProgressComponent.ngOnInit (chart-progress.component.ts:33)
at checkAndUpdateDirectiveInline (core.js:12369)
at checkAndUpdateNodeInline (core.js:13893)
at checkAndUpdateNode (core.js:13836)
at debugCheckAndUpdateNode (core.js:14729)
at debugCheckDirectivesFn (core.js:14670)
at Object.eval [as updateDirectives] (HeaderComponent.html:11)
at Object.debugUpdateDirectives [as updateDirectives] (core.js:14655)
at checkAndUpdateView (core.js:13802)
at callViewAction (core.js:14153)
I think i need your help! Thanks!