New to Kendo UI for Angular? Start a free 30-day trial

Data Binding

The Chat enables you to bind its message list to streaming data.

Data Model

The Chat component defines interfaces for the following entities:

  • User—A unique participant in the conversation.
  • Message—The metadata and content of each message.
  • Attachment—The multimedia or additional information which is associated with a chat message.
  • Action—A suggested quick action in reply to a message. For example, a text reply, external link, or phone call.

As a minimum data-binding configuration for the Chat, provide a list of messages and a user instance which identify the local participant.

User Identity

The user entity identifies the local user. The messages that are authored by the user appear on the right-hand side of the message list.

Example
View Source
Change Theme:

Binding to Message Data

Typically, Chat messages stream from a remote service. To bind the Chat to the stream, utilize the built-in async pipe.

Example
View Source
Change Theme:

Posting Messages

When you set up the messages stream, add the locally posted messages:

  1. Publish the local messages on an observable stream.
  2. Merge the messages with the service responses.

The following example demonstrates how to accept the local messages in the sendMessage event and merge them with the incoming messages.

Example
View Source
Change Theme: