I have two services which one of them(Logger) is going to be used by another(SettingService), I have already searched a lot and see other questions and answers to this problem but no luck, I've already read this document angualr.io/When the service needs a service
here is the code for two services
Logger as a service
@Injectable()
export class Logger {
public logs: string[] = [];
//do stuffs
}
SettingService
@Injectable()
export class SettingService
{
private url = '/setting';
private headers = new Headers({ 'content-type': 'application/json' });
constructor(private http: Http,private logger: Logger) { } //problem is here
//do stuffs
}
the settingService is using both http and logger, I have a component app.component which uses settingService, here is my app.component and app.module
app.component.ts
@Component({
moduleId: module.id,
selector: 'my-app',
templateUrl: 'app.component.html',
styleUrls: ['app.component.css']
})
export class AppComponent implements OnInit {
constructor(private settingService: SettingService) { }
}
app.module.ts
@NgModule({
imports: [ BrowserModule, FormsModule, HttpModule ],
declarations: [AppComponent],
providers: [Logger, SettingService],
bootstrap: [ AppComponent ]
})
export class AppModule { }
but unfortunately I get the error which says :
(SystemJS) Can't resolve all parameters for SettingService: ([object Object], ?).Error: Can't resolve all parameters for SettingService: ([object Object], ?)
what is wrong??
this is plunker, that's not working!
app.component, no luck