Skip to main content
This guide will help you add a custom option to the messages of type image. By default, CometChat UI Kit for Angular supports the following message options: text message - edit, delete, copy, reply in thread, react media message, custom message - delete, reply in thread, react
We recommend that you read the Key Concepts , follow the guidelines, and also take the time to familiarise yourself with the library’s components.
In the example below, we are going to simulate a “download image” feature when user clicks on the custom message option.

Custom Option

The first step is to create the custom option using CometChatMessageOption class which has the following structure:

Click handler

We’ll download the image when user clicks on the custom option.
The download option is then pushed to the default set of options for message type image. The default options for message type image and its template are fetched using the CometChatUIKit class. The download option is then pushed to the default set of message options for image message supported by the Angular UI Kit. The default options are fetched using the CometChatUIKit class.
The message options are then passed to the ConversationsWithMessages component as a prop using MessagesConfiguration.

Implementation

With the completion of each individual piece, we can now integrate all the code snippets to form the final code example.

Code

Result