Interface Overview
interface NgModule {
providers
: Provider[]
declarations
: Array<Type<any>|any[]>
imports
: Array<Type<any>|ModuleWithProviders|any[]>
exports
: Array<Type<any>|any[]>
entryComponents
: Array<Type<any>|any[]>
bootstrap
: Array<Type<any>|any[]>
schemas
: Array<SchemaMetadata|any[]>
id
: string
}
Interface Description
NgModule decorator and metadata.
Interface Details
providers : Provider[]
Defines the set of injectable objects that are available in the injector of this module.
Simple Example
Here is an example of a class that can be injected:
class Greeter {
greet(name:string) {
return 'Hello ' + name + '!';
}
}
@NgModule({
providers: [
Greeter
]
})
class HelloWorld {
greeter:Greeter;
constructor(greeter:Greeter) {
this.greeter = greeter;
}
}
declarations : Array<Type<any>|any[]>
Specifies a list of directives/pipes that belong to this module.
@NgModule({
declarations: [NgFor]
})
class CommonModule {
}
imports : Array<Type<any>|ModuleWithProviders|any[]>
Specifies a list of modules whose exported directives/pipes
should be available to templates in this module.
This can also contain ModuleWithProviders
.
@NgModule({
imports: [CommonModule]
})
class MainModule {
}
exports : Array<Type<any>|any[]>
Specifies a list of directives/pipes/modules that can be used within the template of any component that is part of an Angular module that imports this Angular module.
@NgModule({
exports: [NgFor]
})
class CommonModule {
}
entryComponents : Array<Type<any>|any[]>
Specifies a list of components that should be compiled when this module is defined.
For each component listed here, Angular will create a ComponentFactory
and store it in the ComponentFactoryResolver
.
bootstrap : Array<Type<any>|any[]>
Defines the components that should be bootstrapped when
this module is bootstrapped. The components listed here
will automatically be added to entryComponents
.
schemas : Array<SchemaMetadata|any[]>
Elements and properties that are not Angular components nor directives have to be declared in the schema.
Available schemas:
NO_ERRORS_SCHEMA
: any elements and properties are allowed,CUSTOM_ELEMENTS_SCHEMA
: any custom elements (tag name has "-") with any properties are allowed.
id : string
An opaque ID for this module, e.g. a name or a path. Used to identify modules in
getModuleFactory
. If left undefined
, the NgModule
will not be registered with
getModuleFactory
.
exported from @angular/core/index, defined in @angular/core/src/metadata/ng_module.ts