Skip to main content

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

NameTypeDescription
moduleConfigModuleConfigConfiguration of the module.

Returns

fn

▸ (target): void

Parameters
NameType
target(...args: any[]) => T
Returns

void

Defined in

packages/core/src/core/metadata/module.ts:71