Ensure to bring them in when they are required.
In the AppModule
, you will have to import them for inclusion in providers
, declarations
, imports
, and so on.
Similarly, within your components, directives, pipes, modules, services, etc., you must import them again if you wish to utilize them.
For instance:
AppModule
import { HttpModule } from '@angular/http';
@NgModule({
bootstrap: [AppComponent],
declarations: [
AppComponent
],
imports: [
BrowserModule,
FormsModule,
HttpModule
]
})
export class AppModule {
constructor() {
}
}
UserModule
If I need to make HTTP requests in UserModule, then I will need to import the Http module...
import { HttpModule } from '@angular/http';
@NgModule({
imports: [
HttpModule
],
declarations: [],
exports: [
HttpModule
]
})
export class UserModule{
}