Function: MnModule
▸ MnModule<T
>(moduleConfig
): (target
: (...args
: any
[]) => T
) => void
Decorator that mark a class as module.
A module is a container of components. It define the components and depencencies that be usable by its own components.
Remarks
A component must be declared in a module with the declarations
property to be usable and only one module can associate to a component.
Example
A boostrap module named AppModule
that will run AppComponent
on startup, make AccountComponent
usable by AppComponent
.
Provide AccountService
to AccountComponent
and AppComponent
.
@MnModule({
bootstrap: AppComponent,
declarations: [AccountComponent],
providers: [AccountService]
})
export class AppModule {}
Example
A AppModule
module that import the submodule CommonModule
and make its exported components available to the ContactComponent
.
GridComponent
is not exported by CommonModule
so it is not available to ContactComponent
.
@MnModule({
exports: [FormComponent],
declarations: [FormComponent, GridComponent],
})
export class CommonModule {}
@MnModule({
imports: [CommonModule],
declarations: [ContactComponent],
})
export class AppModule {}
Type parameters
Name |
---|
T |
Parameters
Name | Type | Description |
---|---|---|
moduleConfig | ModuleConfig | Configuration of the module. |
Returns
fn
▸ (target
): void
Parameters
Name | Type |
---|---|
target | (...args : any []) => T |
Returns
void