Core Concepts
This page describes the different concepts and how everything works. It is not required to understand this for normal usage, but valuable in case you configure ngx-formbar by yourself or just are curios.
Registration Types
Section titled “Registration Types”In ngx-formbar there are two ways to register controls and validators: token and map.
The differentiation is only relevant for the schematics, as they use this information to decide what kind of file to expect. This is to reduce the amount of work that needs to be done whenever a schematic tries to register a component.
A token based registration uses a custom injection token to provide the registration to the relevant services.
A map based registration uses an object for mapping the keys to the controls. This is then internally translated into the same injection token.
In the end, all values are provided through Angulars dependency injection. The major difference comes from how the injection token is build.
Resolving registrations
Section titled “Resolving registrations”Even though technically nothing prevents you from registering controls and validators through both ways, this should not be done. There is no logic for merging registrations from multiple sources.
If you provide an object based registration to the provideFormbar function and in also add the token to the providers array, there are two possible outcomes:
- You first call
provideFormbarand then add the token: The registrations from the token win - You first add the token, then call
provideFormbar: The registrations from the object win
Realistically there should be no reason to use a combination of both, therefore mixing is not supported.