provideChat()
provideChat is the provider factory that registers @ngaf/chat configuration in Angular's dependency injection system. Call it once in your ApplicationConfig (or at the route level) to set global defaults used by chat composition components.
Signature
| Parameter | Type | Description |
|---|---|---|
config | ChatConfig | Configuration object with optional render registry, avatar label, and assistant name |
Returns: EnvironmentProviders -- created via makeEnvironmentProviders(), compatible with bootstrapApplication, ApplicationConfig, and route-level providers.
What It Does
provideChat() registers a single provider:
This makes the ChatConfig object available throughout the application via the CHAT_CONFIG injection token.
CHAT_CONFIG Injection Token
The token is an InjectionToken<ChatConfig> that can be injected in any component, directive, or service:
Injecting CHAT_CONFIG without calling provideChat() will throw a NullInjectorError. Use inject(CHAT_CONFIG, { optional: true }) if your component should work without global configuration.
Configuration Options
See the ChatConfig API reference for the full interface definition.
| Option | Type | Default | Description |
|---|---|---|---|
avatarLabel | string | "A" | AI avatar badge text |
assistantName | string | "Assistant" | AI assistant display name |
Usage Patterns
Application-Wide Configuration
Route-Level Configuration
Provide different chat configurations for different parts of your application:
Without provideChat()
All chat components work without provideChat(). They use defaults:
- Avatar label:
"A" - Assistant name:
"Assistant" - Generative UI requires
[views]input onChatComponent