Module class

Encapsulates a reusable set of dependency injection configurations.

One or more modules can be used to create an Injector, or a runtime representation of dependency injection. Modules can also be used to add dependency injection to @Directive or @Component-annotated classes.

Other modules are included (include) before providers (provide).

Previously, AngularDart loosely expressed "modules" as a recursive list of both providers and other lists of providers. For example, the following pattern may be re-written to use Module:

// Before.
const carModule = [
  ClassProvider(Car, useClass: AmericanCar),
];

const autoShopModule = [
  carModule,
  ClassProvider(Oil, useClass: GenericOil),
];

// After.
const carModule = Module(
  provide: [
    ClassProvider(Car, useClass: AmericanCar),
  ],
);

const autoShopModule = Module(
  include: [
    carModule,
  ],
  provide: [
    ClassProvider(Oil, useClass: GenericOil),
  ],
);

Constructors

Module({List<Module> include, List<Provider<Object>> provide })
const
factory

Properties

include → List<Module>
final
provide → List<Provider<Object>>
final
hashCode → int
The hash code for this object. [...]
read-only, inherited
runtimeType → Type
A representation of the runtime type of the object.
read-only, inherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
toString() → String
Returns a string representation of this object.
inherited

Operators

operator ==(dynamic other) → bool
The equality operator. [...]
inherited