Search code examples
angularangular5angular2-services

Getting error on ugrading to angular 5 from angular 4 on doing ng build --prod


ERROR in : Can't resolve all parameters for TouchSystemsService in client-src/app/shared/services/touch-systems.service.ts: ([object Object], ?, [object Object]).

this is my service:

export class TouchSystemsService extends BehaviorSubject{
baseUrl: string ;

constructor(public http: HttpClient, private apiEndPoint: string, private 
configService: ConfigService) {
super(null);
this.baseUrl = '/api';

}
public fetchById(id: number, state?: State): Observable<any>
{
    if (!state) {
    let options = this.CreateHeaders();
    return this.http.get<any>(`${this.baseUrl}/${this.apiEndPoint}/${id}`, 
options);
}
const queryStr = `${toDataSourceRequestString(state)}`;
const hasGroups = state.group && state.group.length;
let options = this.CreateHeaders();

let result = this.http.get<any>(`${this.baseUrl}/${this.apiEndPoint}/${id}? 
${queryStr}`, options);
return result;
}

this is a service that extends the above service

export class SizeService extends TouchSystemsService {

dataResult: GridDataResult;

constructor(http: HttpClient, configService: ConfigService) {
super(http, 'size', configService);
}

public read(id:number): Observable<GridDataResult> {
return this.fetchById(id);
}

I am using angular version Angular: 5.2.10


Solution

  • What I was missing is that this service was not getting accessed directly from angular so this doesnt need to be injectable (also no provider is needed for this service).hence removing the "@Injectable" directive and removing it from providers from app.module.ts worked.