Login Register
Code2night
  • Home
  • Blog Archive
  • Learn
    • Tutorials
    • Videos
  • Interview Q&A
  • Languages
    • Angular Angular js ASP.NET Asp.net Core ASP.NET Core, C# C C# C#, ASP.NET Core, Dapper
      C#, ASP.NET Core, Dapper, Entity Framework DotNet HTML/CSS Java JavaScript Node.js Python Python 3.11, Pandas, SQL
      Python 3.11, SQL Python 3.11, SQLAlchemy Python 3.11, SQLAlchemy, SQL Python 3.11, SQLite React Security SQL Server TypeScript
  • Post Blog
  • Tools
    • Beautifiers
      JSON Beautifier HTML Beautifier XML Beautifier CSS Beautifier JS Beautifier SQL Formatter
      Dev Utilities
      JWT Decoder Regex Tester Diff Checker Cron Explainer String Escape Hash Generator Password Generator
      Converters
      Base64 Encode/Decode URL Encoder/Decoder JSON to CSV CSV to JSON JSON to TypeScript Markdown to HTML Number Base Converter Timestamp Converter Case Converter
      Generators
      UUID / GUID Generator Lorem Ipsum QR Code Generator Meta Tag Generator
      Image Tools
      Image Converter Image Resizer Image Compressor Image to Base64 PNG to ICO Background Remover Color Picker
      Text & Content
      Word Counter PDF Editor
      SEO & Web
      SEO Analyzer URL Checker World Clock
  1. Home
  2. Blog
  3. Angular
  4. Tag or mention people like WhatsApp & Skype by using @ in Angular

Tag or mention people like WhatsApp & Skype by using @ in Angular

Date- Jan 16,2022

Updated Mar 2026

10410

Free Download Pay & Download
Angular Mentions Angular js

Understanding the Requirement

In today’s digital communication landscape, the ability to mention users within chat applications has become increasingly relevant. This functionality not only enhances user experience but also helps in organizing conversations and directing messages to specific individuals. Implementing a tagging feature where users can type '@' followed by a name to mention someone is commonly seen in popular messaging platforms like Skype, Slack, and WhatsApp. Understanding the technical requirements and complexities involved in creating such a feature in Angular is crucial for developers.

Angular, being a powerful framework for building dynamic web applications, provides various tools and packages to facilitate this functionality. One such package is Angular-Mentions, which simplifies the process of implementing user tagging in chat interfaces. This package allows developers to create a user-friendly mention system with minimal effort.

Prerequisites

Before diving into the implementation, it is essential to ensure that you have the following prerequisites:

  • Node.js: Ensure that Node.js is installed on your machine to manage packages using npm.
  • Angular CLI: Familiarity with Angular CLI will help in setting up and managing your Angular projects.
  • Basic Understanding of Angular: A foundational knowledge of Angular components, modules, and templates will be beneficial.

Installing Angular-Mentions

To get started with the tagging feature, you need to install the Angular-Mentions package. This can be done easily using npm. Open your terminal and run the following command:

npm install angular-mentions

After the installation completes, you will need to rebuild your project to ensure that the new package is included. This can be done by running:

ng serve

Setting Up Angular-Mentions in Your Component

Once you have installed the package, you need to import it into your Angular component. This is done by adding the MentionModule to your module imports. Here’s how you can do that:

import { MentionModule } from 'angular-mentions';

@NgModule({
  imports: [
    MentionModule,
    // other imports
  ],
  // other properties
})

Next, you can use the mention directive in your input element. This directive will enable the mention functionality in your chat input. Here’s an example of how to set it up:

@Component({
  selector: 'app-chat',
  template: `
    
  `
})
export class ChatComponent {
  items: string[] = ["Noah", "Liam", "Mason", "Jacob"];
}
Tag or mention people like WhatsApp  Skype by using  in Angular

Using the Mention Functionality

With the mention directive in place, users can now type '@' in the input field to see a list of users to mention. The items array contains the names of users, which will be displayed as suggestions. When a user selects a name from the dropdown, it will be inserted into the input field, allowing for seamless tagging.

To enhance the user experience, you may want to implement additional features such as filtering the list of users based on the characters typed after '@'. This will make it easier for users to find the person they want to mention, especially in larger groups.

filterItems(query: string): string[] {
  return this.items.filter(item => item.toLowerCase().includes(query.toLowerCase()));
}

Edge Cases & Gotchas

While implementing the mention functionality, there are several edge cases and potential gotchas to be aware of:

  • Empty Input Handling: Ensure that the input field gracefully handles cases where no user is selected after typing '@'. You may want to clear the input or provide a default message.
  • Performance Considerations: If your list of users is large, consider implementing lazy loading or pagination to improve performance and user experience.
  • Keyboard Navigation: Users should be able to navigate through the suggestions using their keyboard. Implementing arrow key support can significantly enhance usability.
  • Styling the Dropdown: Make sure the dropdown that appears for mentions is styled appropriately to match the rest of your application.

Performance & Best Practices

To optimize the mention functionality in your Angular application, consider the following best practices:

  • Debouncing Input: Implement debouncing on the input to reduce the number of times the filtering function is called. This will enhance performance, especially for large datasets.
  • Throttling API Calls: If the list of users is fetched from an API, ensure that calls are throttled to prevent overwhelming the server with requests.
  • Accessibility: Ensure that your mention system is accessible. Provide ARIA attributes and ensure that it can be navigated using the keyboard.
  • Testing: Write unit tests for your mention functionality to ensure that it behaves as expected in various scenarios.

Conclusion

Implementing a user mention feature in Angular can significantly enhance your chat application's functionality. By using the Angular-Mentions package, you can create a seamless experience for users to mention others in conversations.

Key Takeaways:

  • Understand the requirements and complexities of implementing user mentions.
  • Install and set up the Angular-Mentions package in your Angular project.
  • Handle edge cases and performance considerations to provide a smooth user experience.
  • Follow best practices to ensure your mention functionality is efficient and accessible.

S
Shubham Batra
Programming author at Code2Night — sharing tutorials on ASP.NET, C#, and more.
View all posts →

Related Articles

Angular Material Select Dropdown with Image
Dec 13, 2022
Understanding Data Binding in Angular: Mastering One-way and Two-way Binding
Mar 25, 2026
Mastering RxJS Observables in Angular: A Comprehensive Guide
Mar 25, 2026
Attribute of table in HTML
Dec 09, 2023
Previous in Angular
How to Apply css on child components in Angular
Next in Angular
Angular Material Select Dropdown with Image

Comments

On this page

More in Angular

  • How to Apply css on child components in Angular 10185 views
  • Export to Excel in Angular using ExcelJS? 9788 views
  • How To Consume Web API Using Angular 4019 views
  • Mastering Angular Directives: ngIf, ngFor, and ngSwitch Expl… 39 views
  • Mastering HTTP Client in Angular: A Comprehensive Guide to R… 35 views
View all Angular posts →

Tags

AspNet C# programming AspNet MVC c programming AspNet Core C software development tutorial MVC memory management Paypal coding coding best practices data structures programming tutorial tutorials object oriented programming Slick Slider StripeNet
Free Download for Youtube Subscribers!

First click on Subscribe Now and then subscribe the channel and come back here.
Then Click on "Verify and Download" button for download link

Subscribe Now | 1770
Download
Support Us....!

Please Subscribe to support us

Thank you for Downloading....!

Please Subscribe to support us

Continue with Downloading
Be a Member
Join Us On Whatsapp
Code2Night

A community platform for sharing programming knowledge, tutorials, and blogs. Learn, write, and grow with developers worldwide.

Panipat, Haryana, India
info@code2night.com
Quick Links
  • Home
  • Blog Archive
  • Tutorials
  • About Us
  • Contact
  • Privacy Policy
  • Terms & Conditions
  • Guest Posts
  • SEO Analyzer
Dev Tools
  • JSON Beautifier
  • HTML Beautifier
  • CSS Beautifier
  • JS Beautifier
  • SQL Formatter
  • Diff Checker
  • Regex Tester
  • Markdown to HTML
  • Word Counter
More Tools
  • Password Generator
  • QR Code Generator
  • Hash Generator
  • Base64 Encoder
  • JWT Decoder
  • UUID Generator
  • Image Converter
  • PNG to ICO
  • SEO Analyzer
By Language
  • Angular
  • Angular js
  • ASP.NET
  • Asp.net Core
  • ASP.NET Core, C#
  • C
  • C#
  • C#, ASP.NET Core, Dapper
  • C#, ASP.NET Core, Dapper, Entity Framework
  • DotNet
  • HTML/CSS
  • Java
  • JavaScript
  • Node.js
  • Python
  • Python 3.11, Pandas, SQL
  • Python 3.11, SQL
  • Python 3.11, SQLAlchemy
  • Python 3.11, SQLAlchemy, SQL
  • Python 3.11, SQLite
  • React
  • Security
  • SQL Server
  • TypeScript
© 2026 Code2Night. All Rights Reserved.
Made with for developers  |  Privacy  ·  Terms
Translate Page
We use cookies to improve your experience and analyze site traffic. By clicking Accept, you consent to our use of cookies. Privacy Policy
Accessibility
Text size
High contrast
Grayscale
Dyslexia font
Highlight links
Pause animations
Large cursor