i have a following class like this
import { Injectable, Inject } from '@angular/core';
@Injectable()
export class moviindustry {
constructor(private music:musicindustry) { }
producer() {
this.music.album();
alert('moviindustry producer');
}
directort() {
alert('moviindustry directort');
}
crew() {
alert('moviindustry crew');
}
}
export class musicindustry {
album() {
alert('album')
}
}
and i have registered the class in the NgModule like this
@NgModule({
declarations: [
AppComponent,
ComponentAComponent
],
imports: [
BrowserModule,
HttpModule
],
providers: [
moviindustry,
musicindustry
],
bootstrap: [AppComponent]
})
export class AppModule { }
now when i try to access the class like this
export class AppComponent {
constructor(private movies:moviindustry){
this.movies.producer();
}
}
i am getting the following error
Uncaught Error: Can't resolve all parameters for moviindustry: (?). at syntaxError (compiler.es5.js:1694)
as per the documentation, Injectable() is used to inject dependency injection for the class, then why am i not able to use it? ironically, my app gets compiled when i use the http in the constructor, can someone help me to understand this
NOTE:
i am not able to use like this either
constructor(@Inject(musicindustry) private music:musicindustry) { }