I have two services/providers: APIRequest
and Auth
. I need to have instance of each one inside the other.
NgModule
looks like this:
// Providers
import { Auth } from '../providers/auth';
import { APIRequest } from '../providers/api-request';
@NgModule({
providers: [
Auth, APIRequest, Storage,
{
provide: ErrorHandler,
useClass: IonicErrorHandler
}
]
})
Auth.ts
like this
import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import { Events } from 'ionic-angular';
import { Storage } from '@ionic/storage';
import { APIRequest } from './api-request'
@Injectable()
export class Auth {
constructor(
private events: Events,
private storage: Storage,
private http: Http,
private apiRequest: APIRequest
) {}
APIRequest.ts
like this:
import { Injectable } from '@angular/core';
import { Http, XHRBackend, RequestOptions, Request, RequestOptionsArgs, Response, Headers } from '@angular/http';
import { Events } from 'ionic-angular';
import { Storage } from '@ionic/storage';
import { Auth } from './auth';
@Injectable()
export class APIRequest extends Http {
constructor (
backend: XHRBackend,
options: RequestOptions,
private storage: Storage,
private events: Events,
private auth: Auth
) {
super(backend, options)
}
The error I get: Uncaught Error: Can’t resolve all parameters for Auth: (Events, Storage, Http, ?).