I'm trying to inject a service inside another service:
- instagram.service > event.service.ts(main service) Where the instagram is the service that is going to be injected inside the event.service.
I have declared the instagram.service.ts in the app.module.
The error that I get is:
Uncaught Error: Can't resolve all parameters for Instagram: (?). at syntaxError (compiler.js:1021) at CompileMetadataResolver.push../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver._getDependenciesMetadata (compiler.js:10922) at CompileMetadataResolver.push../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver._getTypeMetadata (compiler.js:10815) at CompileMetadataResolver.push../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver._getInjectableTypeMetadata (compiler.js:11037) at CompileMetadataResolver.push../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver.getProviderMetadata (compiler.js:11046) at compiler.js:10984 at Array.forEach () at CompileMetadataResolver.push../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver._getProvidersMetadata (compiler.js:10944) at CompileMetadataResolver.push../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver.getNgModuleMetadata (compiler.js:10663) at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._loadModules (compiler.js:23876)
After running some tests I noticed that the error only happens when I import the Http component (that's also declared on the app.module).
Am I missing something here?
events.service.ts
import { Injectable } from '@angular/core';
import { AngularFireStorage } from '@angular/fire/storage';
import { Event } from './events.model';
import { AngularFireDatabase, AngularFireList } from '@angular/fire/database';
import { Instagram } from './instagram.service';
@Injectable()
export class EventService {
event: AngularFireList<Event[]>;
NODE = 'events/';
constructor(private instagram: Instagram, private db: AngularFireDatabase, private storage: AngularFireStorage) {}
getAllPictures(tag: string) {
this.instagram.getAllPictures(tag);
}
}
instagram.service.ts
import { Http } from '@angular/http';
export class Instagram {
tag: string;
private BASE_URL = 'https://www.instagram.com/explore/tags/' + this.tag + '/?__a=1';
constructor(public http: Http) {}
getAllPictures(tag: string) {
this.tag = tag;
return this.http.get(this.BASE_URL).pipe().subscribe(
data => {
console.log(data);
},
(error) => {
console.log(error);
}
);
}
}