elements / Function

provideElements

Offers a declarative approach to register Angular Elements.

Notes

The returned providers are for EnvironmentInjector only, e.g. app.config.ts, route declarations, and NgModules. The registered Angular Elements will not be unregistered when the EnvironmentInjector is destroyed, so make sure the EnvironmentInjector will not be destroyed anytime in the application's lifecycle.

Presentation

Returns

Parameters

NameTypeDescription
config
ProvideElementsConfig

Example usage

export const APP_ELEMENTS: Elements = {
  'my-button': ButtonComponent,
  'my-icon': IconComponent,
  'my-icon-button': IconButtonComponent,
};
providers: [
  provideElements({ elements: APP_ELEMENTS }),
]