Ok, so I've realized that my services are very copy and paste. So I wanted to take a stab at super classes and inheritance in Angular. Not going as well as I want it to. I'm really getting hung up on the constructor and super calls. TS compiles correctly and with no errors, but the is what I get in console.
core.js:12632 ERROR Error: Uncaught (in promise): TypeError: this.http.get is not a function
Now, I'm assuming this is going to continue for all of my dependencies.
Here is my BaseService Class:
import {EventEmitter, Output} from '@angular/core';
import { environment } from '../../environments/environment';
export abstract class BaseService {
@Output() saving = new EventEmitter();
constructor(
public api_url: string,
public success_message: string,
public success_url: string,
public nav_to_view: boolean,
public http,
public toaster,
public router,
) {
this.api_url = environment.api + this.api_url;
}
list() {
return this.http.get(this.api_url);
}
}
and here is my service that is extending BaseService:
import {Injectable} from '@angular/core';
import {BaseService} from '../../core/base.service';
import {HttpClient} from '@angular/common/http';
import {ToastrService} from 'ngx-toastr';
import {Router} from '@angular/router';
@Injectable()
export class ModulesService extends BaseService {
constructor() {
super('/modules', 'Manufacturer Saved!', '/modules', false, HttpClient, ToastrService, Router);
}
}
What am I not understanding? Thank you in advance!