Loading...
Loading...
Implement the Syncfusion Angular Mention component for user tagging with autocomplete suggestions in contenteditable elements. Covers data binding (local/remote), filtering, templates, sorting, disabled items, localization, accessibility, and popup customization. Use this when adding @mention or tag functionality to Angular applications, configuring trigger characters, customizing suggestion templates, or ensuring accessibility compliance.
npx skill4agent add syncfusion/angular-ui-components-skills syncfusion-angular-mention@div[contenteditable]textarea@#/contenteditableContainsStartsWithEndsWith| Aspect | Details |
|---|---|
| Trigger | Any single character via |
| Target | Any |
| Data Sources | Local arrays (strings, objects), remote |
| Filtering | Built-in: |
| Display | |
| Suffix | |
| Accessibility | WCAG 2.2, Section 508, ADA; keyboard shortcuts: Arrow keys, Enter, Tab, Escape |
| Localization | |
@syncfusion/ej2-angular-dropdownsMentionModulecontenteditabletargetdataSourceshowMentionCharmentionChartextvaluegroupByiconCssfieldsDataManagerODataV4AdaptorWebApiAdaptorqueryfilterTypeContainsStartsWithEndsWithminLengthallowSpacessuggestionCountdebounceDelayitemTemplatedisplayTemplatenoRecordsTemplatespinnerTemplategroupTemplateshowMentionCharsuffixTextpopupHeightpopupWidthmentionCharrequireLeadingSpacecssClasshighlightignoreCaseignoreAccentsortOrderNoneAscendingDescendingfields.disableddisableItemaria-selectedaria-activedescendentaria-ownsnoRecordsTemplateL10n.load()enableRtladdItemdisableItemgetDataByValuegetItemshidePopupshowPopupsearchdestroydataBoundactionFailureTemplate// app.component.ts (Angular 21 Standalone)
import { Component } from '@angular/core';
import { MentionModule } from '@syncfusion/ej2-angular-dropdowns';
@Component({
selector: 'app-root',
standalone: true,
imports: [MentionModule],
template: `
<label style="font-size: 15px; font-weight: 600;">Comments</label>
<div id="mentionElement"
placeholder="Type @ and tag a user"
style="min-height: 100px; border: 1px solid #D7D7D7; border-radius: 4px; padding: 8px;">
</div>
<ejs-mention [dataSource]="userData" [target]="mentionTarget"></ejs-mention>
`
})
export class AppComponent {
public userData: string[] = ['Selma Rose', 'Garth', 'Robert', 'William', 'Joseph'];
public mentionTarget: string = '#mentionElement';
}⚠️ Security note: Pin the package to a specific version to prevent unintended upgrades to potentially compromised releases. Verify the installed version against your lockfile (/package-lock.json) after installation.yarn.lock
ng add @syncfusion/ej2-angular-dropdowns@33.1.44styles.css⚠️ Security note: These imports are resolved fromat build time. Ensure the installed Syncfusion packages match your pinned versions innode_modulesorpackage-lock.jsonbefore building. Do not source these files from a CDN without Subresource Integrity (SRI) hashes.yarn.lock
@import '../node_modules/@syncfusion/ej2-base/styles/material3.css';
@import '../node_modules/@syncfusion/ej2-buttons/styles/material3.css';
@import '../node_modules/@syncfusion/ej2-popups/styles/material3.css';
@import '../node_modules/@syncfusion/ej2-lists/styles/material3.css';
@import '../node_modules/@syncfusion/ej2-angular-dropdowns/styles/material3.css';public userData: { [key: string]: Object }[] = [
{ Name: 'Selma Rose', EmailId: 'selma@gmail.com' },
{ Name: 'Maria', EmailId: 'maria@gmail.com' },
{ Name: 'Robert', EmailId: 'robert@gmail.com' }
];
public fields: Object = { text: 'Name' };
public mentionTarget: string = '#mentionElement';<ejs-mention [dataSource]="userData" [fields]="fields" [target]="mentionTarget"></ejs-mention><ejs-mention
[dataSource]="userData"
[target]="mentionTarget"
[mentionChar]="'#'"
[showMentionChar]="true">
</ejs-mention>⚠️ Security note: Replace the URL below with your own API endpoint. Avoid enablingunless your server explicitly requires it and you have validated the CORS policy. Always sanitize or restrict user input before it is forwarded to remote sources, and verify installed packages against your lockfile (crossDomain: true/package-lock.json).yarn.lock
import { DataManager, ODataV4Adaptor, Query } from '@syncfusion/ej2-data';
public searchData: DataManager = new DataManager({
url: 'https://your-api-endpoint.example.com/api/',
adaptor: new ODataV4Adaptor
// crossDomain: true — enable only if your server requires it and CORS is properly configured
});
public query: Query = new Query().from('Customers').select(['ContactName', 'CustomerID']).take(6);
public fields: Object = { text: 'ContactName', value: 'CustomerID' };
public popupWidth: string = '250px';<ejs-mention
[dataSource]="userData"
[fields]="fields"
[allowSpaces]="true"
[target]="mentionTarget">
</ejs-mention>| Property | Type | Default | Purpose |
|---|---|---|---|
| HTMLElement | string | — | Target element where mention suggestions appear |
| Array | DataManager | | Source data for suggestions |
| FieldSettingsModel | | Map data columns to component |
| string | | Character that triggers the suggestion popup |
| boolean | | Show trigger character with inserted text |
| string | | Text appended after the selected item |
| FilterType | | How suggestions are matched |
| number | | Minimum chars to trigger filtering |
| boolean | | Allow spaces in mid-mention search |
| number | | Max number of suggestions shown |
| number | | Delay (ms) before filtering fires |
| SortOrder | | Sort suggestions order |
| string | number | | Popup list height |
| string | number | | Popup list width |
| boolean | | Highlight matched characters |
| boolean | | Case-insensitive search |
| boolean | — | Ignore diacritics in search |
| boolean | | Require space before trigger character |
| string | | Custom CSS class(es) on the component |
| string | | Localization culture |
| boolean | | Right-to-left rendering |
| boolean | | Persist state between reloads |
| number | | Popup z-index |
Need to implement Mention / @mention tagging?
│
├─ What's your data source?
│ ├─ Local strings/array → See Data Binding: "Array of simple data"
│ ├─ Local objects → See Data Binding: "Array of JSON data" + fields mapping
│ └─ Remote API → See Data Binding: "Binding remote data"
│
├─ Custom trigger character (not @)?
│ └─ YES → [mentionChar]="'#'" (or any single char)
│
├─ Show trigger char in inserted text?
│ └─ YES → [showMentionChar]="true"
│
├─ Multi-word names (e.g., "John Doe")?
│ └─ YES → [allowSpaces]="true"
│
├─ Custom item layout in popup?
│ └─ YES → See Templates: itemTemplate / displayTemplate
│
├─ Need sorted suggestions?
│ └─ YES → See Sorting & Disabled Items: sortOrder
│
├─ Some items should not be selectable?
│ └─ YES → See Sorting & Disabled Items: fields.disabled / disableItem
│
├─ Filtering behavior?
│ ├─ By default (Contains) → No extra config
│ ├─ StartsWith / EndsWith → filterType="StartsWith"
│ └─ Minimum typed chars → [minLength]="3"
│
└─ Need accessibility or localization?
└─ YES → See Accessibility & Localization reference