You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|`messages`|Array of messages (`IgcChatMessage[]`) displayed in the chat. You can bind to this to control which messages are shown. |
88
+
|`messages`|Bidirectional array of messages (`IgcChatMessage[]`) displayed in the chat. The Chat updates the supplied collection when the user sends a message.|
89
89
|`draftMessage`| The current unsent message, represented as an object containing `text` and optional `attachments`. This is useful for saving or restoring message drafts. |
90
90
|`options`| Chat configuration (<ApiLinktype="ChatOptions" />) such as current user ID, input placeholders, accepted file types, quick reply suggestions and typing behavior. |
91
91
|`templates`| Custom Angular templates (<ApiLinktype="ChatTemplates" />) for message content, input, attachments, and other parts of the chat UI. |
92
92
93
93
These properties make it straightforward to synchronize the Chat’s UI with your application’s state and backend.
94
94
95
+
#### Bidirectional Messages Collection
96
+
97
+
The `messages` collection is bidirectional: the application provides the messages to display, and the Chat updates the original collection as the conversation continues. After the user sends a message, code holding a reference to the collection can access the newly created message. This is an in-place update to the collection rather than Angular two-way binding with `[(messages)]`.
98
+
99
+
The `messageCreated` event is a notification for persistence or other side effects. Do not append the created message to the collection again.
100
+
101
+
If the original collection must remain unchanged, pass the Chat a shallow copy:
102
+
103
+
```ts
104
+
publicmessages= [...this.originalMessages];
105
+
```
106
+
107
+
Existing message objects are still shared. Create a new instance of each message when building the copied collection if those objects must also remain independent.
108
+
95
109
### Attachments
96
110
Modern conversations are rarely limited to text alone. The Chat component includes built-in support for file attachments, allowing users to share images, documents, and other files.
97
111
By default, the input area includes an attachment button. You can control which file types are allowed by setting the `acceptedFiles` property:
The `Messages` collectionisupdatedautomatically when the user sends a message. You can handle the `MessageCreated` event to persist the message or perform other side effects; do not append the event detail to `Messages` again:
|`messages`| Array of messages (<ApiLinktype="ChatMessage" />[]) displayed in the chat. You can bind to this to control which messages are shown. |
256
-
|`draftMessage`| The current unsent message, represented as an object containing `text` and optional `attachments`. This is useful for saving or restoring message drafts. |
257
-
|`options`| Chat configuration (<ApiLinktype="ChatOptions" />) such as current user ID, input placeholders, accepted file types, quick reply suggestions, typing delay, and custom renderers. |
258
-
|`resourceStrings`| Localized resource strings for labels, headers, and system text. Use this property to adapt the component for different languages. |
|<PlatformBlockfor="Blazor">`ResourceStrings`</PlatformBlock><PlatformBlock for="WebComponents,React">`resourceStrings`</PlatformBlock> | Localized resource strings for labels, headers, and system text. Use this property to adapt the component for different languages. |
259
259
260
260
These properties make it straightforward to synchronize the Chat’s UI with your application’s state and backend.
261
261
262
+
#### Bidirectional Messages Collection
263
+
264
+
The <PlatformBlock for="WebComponents,React">`messages`</PlatformBlock><PlatformBlock for="Blazor">`Messages`</PlatformBlock> collection is bidirectional: the application provides the messages to display, and the Chat updates the original collection as the conversation continues. After the user sends a message, code holding a reference to the collection can access the newly created message.
265
+
266
+
The <PlatformBlock for="WebComponents">`igcMessageCreated`</PlatformBlock><PlatformBlock for="React">`onMessageCreated`</PlatformBlock><PlatformBlock for="Blazor">`MessageCreated`</PlatformBlock> event is a notification for persistence or other side effects. Do not append the created message to the collection again.
267
+
268
+
If the original collection must remain unchanged, pass the Chat a shallow copy. Existing message objects are still shared; createanewinstanceofeachmessagewhenbuildingthecopiedcollectionifthoseobjectsmustalsoremainindependent.
0 commit comments