syncfusion-angular-popups
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseImplementing Syncfusion Angular Popups
实现Syncfusion Angular弹窗组件
Dialog
Dialog
The Dialog component is a window that displays information to the user and is used to get user input. It supports both modal dialogs (blocking parent interaction) and modeless dialogs (allowing parent interaction).
Dialog组件是向用户展示信息并获取用户输入的窗口。它支持模态对话框(阻止父组件交互)和非模态对话框(允许父组件交互)两种模式。
Component Overview
组件概述
Key Features
核心特性
- Modal & Modeless modes - Block or allow parent interaction
- Templates - Customizable headers, content, and footers
- Positioning - 9 built-in positions or custom placement
- Animations - Smooth open/close effects (Fade, Zoom, Slide)
- Draggable & Resizable - Allow users to move and resize dialogs
- Forms Integration - Reactive and template-driven forms
- Accessibility - Full WCAG 2.2 Level AA support with ARIA
- Keyboard Navigation - Tab, Escape, Enter, and arrow keys
- Responsive - Full-screen mode on mobile devices
- 模态与非模态模式 - 阻止或允许父组件交互
- 模板定制 - 可自定义头部、内容和底部
- 定位功能 - 9种内置位置或自定义布局
- 动画效果 - 流畅的打开/关闭动画(淡入、缩放、滑动)
- 可拖拽与调整大小 - 允许用户移动和调整对话框尺寸
- 表单集成 - 支持响应式表单和模板驱动表单
- 无障碍支持 - 全面符合WCAG 2.2 Level AA标准,支持ARIA属性
- 键盘导航 - 支持Tab、Escape、Enter和方向键操作
- 响应式设计 - 在移动设备上自动切换为全屏模式
Documentation and Navigation Guide
文档与导航指南
When you need to implement Dialog features, follow these references:
当你需要实现Dialog功能时,请参考以下文档:
Getting Started
快速入门
📄 Read: references/dialog-getting-started.md
- Installation and setup in Angular 21+
- Basic dialog implementation
- CSS imports and themes
- Opening and closing dialogs
- Built-in button support
📄 阅读: references/dialog-getting-started.md
- Angular 21+中的安装与配置
- 基础Dialog实现
- CSS导入与主题设置
- 对话框的打开与关闭
- 内置按钮支持
Dialog Modes & Types
对话框模式与类型
📄 Read: references/dialog-modal-vs-modeless.md
- Modal dialog behavior (blocks parent interaction)
- Modeless dialog behavior (allows parent interaction)
- Use cases and when to use each mode
- Toggling between modes
- Overlay customization and styling
📄 阅读: references/dialog-modal-vs-modeless.md
- 模态对话框行为(阻止父组件交互)
- 非模态对话框行为(允许父组件交互)
- 使用场景及模式选择
- 模式切换方法
- 遮罩层定制与样式设置
Content & Templates
内容与模板
📄 Read: references/dialog-templates-and-content.md
- Header templates and customization
- Content as strings, HTML, or ng-template
- Footer templates with buttons
- Using ng-content for dynamic content
- Button binding and click events
- Dynamic button arrays
📄 阅读: references/dialog-templates-and-content.md
- 头部模板定制
- 内容支持字符串、HTML或ng-template
- 带按钮的底部模板
- 使用ng-content实现动态内容
- 按钮绑定与点击事件处理
- 动态按钮数组配置
Positioning & Sizing
定位与尺寸设置
📄 Read: references/dialog-positioning-and-sizing.md
- Built-in positions (9 locations: Top, Center, Bottom, etc.)
- Custom positioning with X, Y coordinates
- Width and height configuration
- Min/max height constraints
- Responsive sizing on different screen sizes
- Full-screen mode on mobile devices
📄 阅读: references/dialog-positioning-and-sizing.md
- 内置位置(9种:顶部、居中、底部等)
- 通过X、Y坐标自定义定位
- 宽度与高度配置
- 最小/最大高度限制
- 不同屏幕尺寸下的响应式尺寸
- 移动设备上的全屏模式
Styling & Customization
样式与定制
📄 Read: references/dialog-styling-and-customization.md
- CSS class customization (header, content, footer, overlay)
- Theme integration (Material, Bootstrap, Tailwind, Fluent)
- Dark mode support
- Animation effects (Fade, Zoom, SlideLeft, SlideRight, etc.)
- Icon customization (close button, resize handles)
- RTL (Right-to-Left) language support
📄 阅读: references/dialog-styling-and-customization.md
- CSS类定制(头部、内容、底部、遮罩层)
- 主题集成(Material、Bootstrap、Tailwind、Fluent)
- 深色模式支持
- 动画效果(淡入、缩放、左滑、右滑等)
- 图标定制(关闭按钮、调整大小手柄)
- RTL(从右到左)语言支持
Accessibility & Forms
无障碍与表单
📄 Read: references/dialog-accessibility-and-forms.md
- WCAG 2.2 Level AA compliance standards
- ARIA attributes (aria-labelledby, aria-describedby, aria-modal, aria-grabbed)
- Keyboard navigation patterns (Tab, Shift+Tab, Escape, Enter)
- Screen reader support and best practices
- Form validation with FormValidator
- Reactive forms patterns
- Template-driven forms patterns
- Custom validation rules and error handling
📄 阅读: references/dialog-accessibility-and-forms.md
- WCAG 2.2 Level AA合规标准
- ARIA属性(aria-labelledby、aria-describedby、aria-modal、aria-grabbed)
- 键盘导航模式(Tab、Shift+Tab、Escape、Enter)
- 屏幕阅读器支持与最佳实践
- 结合FormValidator的表单验证
- 响应式表单模式
- 模板驱动表单模式
- 自定义验证规则与错误处理
Interaction & Events
交互与事件
📄 Read: references/dialog-interaction-and-events.md
- Dialog open/close events
- Draggable dialogs (allow users to move dialogs)
- Resizable dialogs (allow users to resize)
- Button click events and handling
- Content interaction patterns
- Preventing dialog closure
- Focus management
- Dialog lifecycle events
📄 阅读: references/dialog-interaction-and-events.md
- 对话框打开/关闭事件
- 可拖拽对话框(允许用户移动)
- 可调整大小的对话框(允许用户调整尺寸)
- 按钮点击事件与处理
- 内容交互模式
- 阻止对话框关闭
- 焦点管理
- 对话框生命周期事件
Advanced Patterns
高级模式
📄 Read: references/dialog-advanced-patterns.md
- Nested dialogs (dialog within dialog)
- Ajax-loaded content dynamically
- Utility functions for programmatic creation
- Complex layouts (Rich Text Editor, multi-step forms)
- Scroll handling and auto-centering
- Custom event emitters
- Routing integration patterns
📄 阅读: references/dialog-advanced-patterns.md
- 嵌套对话框(对话框内嵌套对话框)
- 动态加载Ajax内容
- 程序化创建的工具函数
- 复杂布局(富文本编辑器、多步骤表单)
- 滚动处理与自动居中
- 自定义事件发射器
- 路由集成模式
API Reference (Complete)
完整API参考
📄 Read: references/dialog-api-reference.md
- Complete Dialog API documentation
- All valid properties with types and examples
- All methods (show, hide, refresh, destroy)
- All events (beforeOpen, beforeClose, drag, resize, etc.)
- Interfaces and models (AnimationSettingsModel, ButtonPropsModel, etc.)
- Valid enumerations (DialogEffect, ResizeDirections)
- Official Syncfusion documentation links
📄 阅读: references/dialog-api-reference.md
- 完整的Dialog API文档
- 所有有效属性的类型与示例
- 所有方法(show、hide、refresh、destroy)
- 所有事件(beforeOpen、beforeClose、drag、resize等)
- 接口与模型(AnimationSettingsModel、ButtonPropsModel等)
- 有效枚举(DialogEffect、ResizeDirections)
- Syncfusion官方文档链接
Quick Start Example
快速入门示例
Here's a minimal example to open a basic modal dialog:
typescript
import { Component, ViewChild } from '@angular/core';
import { DialogModule, DialogComponent } from '@syncfusion/ej2-angular-popups';
@Component({
selector: 'app-root',
imports: [DialogModule],
template: `
<div id="dialog-container" style="height: 500px;">
<button class="e-control e-btn" (click)="onOpenDialog()">
Open Dialog
</button>
<ejs-dialog
#ejDialog
target="#dialog-container"
[showCloseIcon]="true"
width="400px"
content="This is a Dialog content"
>
<ng-template #header>
<div class="e-dlg-header-content">
<span>Dialog Title</span>
</div>
</ng-template>
</ejs-dialog>
</div>
`
})
export class AppComponent {
@ViewChild('ejDialog') ejDialog!: DialogComponent;
onOpenDialog(): void {
this.ejDialog.show();
}
}CSS:
css
#dialog-container {
height: 500px;
}以下是打开基础模态对话框的最简示例:
typescript
import { Component, ViewChild } from '@angular/core';
import { DialogModule, DialogComponent } from '@syncfusion/ej2-angular-popups';
@Component({
selector: 'app-root',
imports: [DialogModule],
template: `
<div id="dialog-container" style="height: 500px;">
<button class="e-control e-btn" (click)="onOpenDialog()">
Open Dialog
</button>
<ejs-dialog
#ejDialog
target="#dialog-container"
[showCloseIcon]="true"
width="400px"
content="This is a Dialog content"
>
<ng-template #header>
<div class="e-dlg-header-content">
<span>Dialog Title</span>
</div>
</ng-template>
</ejs-dialog>
</div>
`
})
export class AppComponent {
@ViewChild('ejDialog') ejDialog!: DialogComponent;
onOpenDialog(): void {
this.ejDialog.show();
}
}CSS:
css
#dialog-container {
height: 500px;
}Common Patterns
常见模式
Pattern 1: Modal Confirmation Dialog
模式1:模态确认对话框
typescript
// Create a modal dialog for confirmation
<ejs-dialog
[isModal]="true"
[showCloseIcon]="true"
width="350px"
content="Are you sure you want to delete this item?"
>
<ng-template #footer>
<button class="e-control e-btn e-primary" (click)="onConfirm()">
Yes, Delete
</button>
<button class="e-control e-btn" (click)="onCancel()">
Cancel
</button>
</ng-template>
</ejs-dialog>typescript
// 创建用于确认的模态对话框
<ejs-dialog
[isModal]="true"
[showCloseIcon]="true"
width="350px"
content="Are you sure you want to delete this item?"
>
<ng-template #footer>
<button class="e-control e-btn e-primary" (click)="onConfirm()">
Yes, Delete
</button>
<button class="e-control e-btn" (click)="onCancel()">
Cancel
</button>
</ng-template>
</ejs-dialog>Pattern 2: Dialog with Form (Reactive Forms)
模式2:包含表单的对话框(响应式表单)
typescript
// Dialog containing a reactive form
<ejs-dialog [showCloseIcon]="true" width="450px">
<form [formGroup]="form">
<div class="e-dlg-content">
<input formControlName="name" placeholder="Enter name" />
<input formControlName="email" placeholder="Enter email" />
</div>
</form>
<ng-template #footer>
<button class="e-control e-btn e-primary" (click)="onSubmit()">
Submit
</button>
</ng-template>
</ejs-dialog>typescript
// 包含响应式表单的对话框
<ejs-dialog [showCloseIcon]="true" width="450px">
<form [formGroup]="form">
<div class="e-dlg-content">
<input formControlName="name" placeholder="Enter name" />
<input formControlName="email" placeholder="Enter email" />
</div>
</form>
<ng-template #footer>
<button class="e-control e-btn e-primary" (click)="onSubmit()">
Submit
</button>
</ng-template>
</ejs-dialog>Pattern 3: Positioned Dialog
模式3:自定义定位的对话框
typescript
// Dialog positioned at a specific location
<ejs-dialog
[position]="{ X: 100, Y: 50 }"
width="400px"
content="Positioned Dialog"
>
</ejs-dialog>typescript
// 定位在特定位置的对话框
<ejs-dialog
[position]="{ X: 100, Y: 50 }"
width="400px"
content="Positioned Dialog"
>
</ejs-dialog>Key Props Quick Reference
核心属性速查
| Property | Type | Purpose | Example |
|---|---|---|---|
| boolean | Block parent interaction | |
| boolean | Show close button in header | |
| string | number | Set dialog width | |
| string | number | Set dialog height | |
| string | number | Minimum height constraint | |
| PositionDataModel | Set position (X, Y) or preset | |
| HTMLElement | string | Set container element | |
| string | HTMLElement | Set content text or HTML | |
| string | HTMLElement | Set header text or element | |
| ButtonPropsModel[] | Add footer buttons | |
| boolean | Close on Escape key | |
| boolean | Enable header dragging | |
| boolean | Enable resizing | |
| ResizeDirections[] | Specify resize directions | |
| string | Custom CSS class(es) | |
| AnimationSettingsModel | Configure animations | |
| boolean | Save state between reloads | |
| number | Z-order for layering | |
| 属性 | 类型 | 用途 | 示例 |
|---|---|---|---|
| boolean | 阻止父组件交互 | |
| boolean | 在头部显示关闭按钮 | |
| string | number | 设置对话框宽度 | |
| string | number | 设置对话框高度 | |
| string | number | 最小高度限制 | |
| PositionDataModel | 设置位置(X、Y)或预设值 | |
| HTMLElement | string | 设置容器元素 | |
| string | HTMLElement | 设置内容文本或HTML | |
| string | HTMLElement | 设置头部文本或元素 | |
| ButtonPropsModel[] | 添加底部按钮 | |
| boolean | 按Escape键关闭 | |
| boolean | 启用头部拖拽 | |
| boolean | 启用尺寸调整 | |
| ResizeDirections[] | 指定调整方向 | |
| string | 自定义CSS类 | |
| AnimationSettingsModel | 配置动画效果 | |
| boolean | 在页面重载时保存状态 | |
| number | 层级堆叠顺序 | |
Common Use Cases
常见使用场景
- Confirmation before delete - Modal dialog asking user to confirm deletion
- Form submission - Dialog with form for user to submit data
- Alerts and notifications - Display important information to users
- Multi-step processes - Use nested dialogs for workflows
- Settings panels - Modeless dialog for settings that don't block interaction
- Help and guidance - Display help content in a draggable dialog
- Loading states - Show progress in a dialog while processing
- Error handling - Display error messages in a modal
- 删除前确认 - 模态对话框询问用户是否确认删除
- 表单提交 - 包含表单的对话框,用于用户提交数据
- 警告与通知 - 向用户展示重要信息
- 多步骤流程 - 使用嵌套对话框实现工作流
- 设置面板 - 非模态对话框,不阻止用户交互
- 帮助与指引 - 在可拖拽对话框中展示帮助内容
- 加载状态 - 在处理过程中展示进度对话框
- 错误处理 - 在模态对话框中展示错误信息
Related Skills
相关技能
- Dialog Animation - Customize open/close animations
- Form Validation - Validate user input in dialogs
- Routing Integration - Use dialogs with Angular routing
- 对话框动画 - 自定义打开/关闭动画
- 表单验证 - 验证对话框中的用户输入
- 路由集成 - 在Angular路由中使用对话框
Predefined Dialogs
预定义对话框
This skill covers building alert, confirm, and prompt dialogs using Syncfusion's — a zero-template, utility-first approach to displaying modal feedback and user-input dialogs in Angular applications.
DialogUtility本部分介绍如何使用Syncfusion的构建警告、确认和提示对话框——这是一种无需模板、实用优先的方法,用于在Angular应用中展示模态反馈和用户输入对话框。
DialogUtilityWhich Dialog Type?
如何选择对话框类型?
| Need | Dialog Type | API |
|---|---|---|
| Warn/inform user, single OK | Alert | |
| Ask for confirmation (OK + Cancel) | Confirm | |
| Collect user input (HTML content + OK + Cancel) | Prompt | |
Key insight: Angular's predefined dialogs have no separate "prompt" method — usewith custom HTML in theDialogUtility.confirm()property to build a prompt pattern.content
| 需求 | 对话框类型 | API |
|---|---|---|
| 警告/通知用户,仅需确认按钮 | 警告对话框 | |
| 请求用户确认(确认+取消按钮) | 确认对话框 | |
| 收集用户输入(HTML内容+确认+取消按钮) | 提示对话框 | 在 |
核心提示: Angular的预定义对话框没有单独的"prompt"方法——使用并在DialogUtility.confirm()属性中添加自定义HTML来实现提示对话框模式。content
Quick Start
快速入门
bash
ng add @syncfusion/ej2-angular-popupstypescript
// src/app/app.ts
import { Component } from '@angular/core';
import { DialogModule } from '@syncfusion/ej2-angular-popups';
import { ButtonModule } from '@syncfusion/ej2-angular-buttons';
import { DialogUtility } from '@syncfusion/ej2-popups';
@Component({
selector: 'app-root',
standalone: true,
imports: [DialogModule, ButtonModule],
template: `
<button ejs-button cssClass="e-danger" (click)="showAlert()">Alert</button>
<button ejs-button cssClass="e-success" (click)="showConfirm()" style="margin-left:8px">Confirm</button>
<button ejs-button [isPrimary]="true" (click)="showPrompt()" style="margin-left:8px">Prompt</button>
`
})
export class App {
showAlert(): void {
DialogUtility.alert({
title: 'Warning',
content: 'Disk space is running low.',
width: '280px'
});
}
showConfirm(): void {
const dlg = DialogUtility.confirm({
title: 'Delete Item',
content: 'Are you sure you want to delete this item?',
width: '300px',
okButton: { text: 'Yes', click: () => { dlg.hide(); /* handle confirm */ } },
cancelButton: { text: 'No', click: () => { dlg.hide(); } }
});
}
showPrompt(): void {
const dlg = DialogUtility.confirm({
title: 'Enter Name',
content: '<p>Your name:</p><input id="nameInput" class="e-input" type="text" placeholder="Type here..." />',
width: '300px',
okButton: {
text: 'Submit',
click: () => {
const value = (document.getElementById('nameInput') as HTMLInputElement).value;
dlg.hide();
// use value
}
},
cancelButton: { text: 'Cancel', click: () => dlg.hide() }
});
}
}css
/* styles.css */
@import '../node_modules/@syncfusion/ej2-base/styles/material3.css';
@import '../node_modules/@syncfusion/ej2-icons/styles/material3.css';
@import '../node_modules/@syncfusion/ej2-buttons/styles/material3.css';
@import '../node_modules/@syncfusion/ej2-angular-popups/styles/material3.css';bash
ng add @syncfusion/ej2-angular-popupstypescript
// src/app/app.ts
import { Component } from '@angular/core';
import { DialogModule } from '@syncfusion/ej2-angular-popups';
import { ButtonModule } from '@syncfusion/ej2-angular-buttons';
import { DialogUtility } from '@syncfusion/ej2-popups';
@Component({
selector: 'app-root',
standalone: true,
imports: [DialogModule, ButtonModule],
template: `
<button ejs-button cssClass="e-danger" (click)="showAlert()">Alert</button>
<button ejs-button cssClass="e-success" (click)="showConfirm()" style="margin-left:8px">Confirm</button>
<button ejs-button [isPrimary]="true" (click)="showPrompt()" style="margin-left:8px">Prompt</button>
`
})
export class App {
showAlert(): void {
DialogUtility.alert({
title: 'Warning',
content: 'Disk space is running low.',
width: '280px'
});
}
showConfirm(): void {
const dlg = DialogUtility.confirm({
title: 'Delete Item',
content: 'Are you sure you want to delete this item?',
width: '300px',
okButton: { text: 'Yes', click: () => { dlg.hide(); /* handle confirm */ } },
cancelButton: { text: 'No', click: () => { dlg.hide(); } }
});
}
showPrompt(): void {
const dlg = DialogUtility.confirm({
title: 'Enter Name',
content: '<p>Your name:</p><input id="nameInput" class="e-input" type="text" placeholder="Type here..." />',
width: '300px',
okButton: {
text: 'Submit',
click: () => {
const value = (document.getElementById('nameInput') as HTMLInputElement).value;
dlg.hide();
// use value
}
},
cancelButton: { text: 'Cancel', click: () => dlg.hide() }
});
}
}css
/* styles.css */
@import '../node_modules/@syncfusion/ej2-base/styles/material3.css';
@import '../node_modules/@syncfusion/ej2-icons/styles/material3.css';
@import '../node_modules/@syncfusion/ej2-buttons/styles/material3.css';
@import '../node_modules/@syncfusion/ej2-angular-popups/styles/material3.css';Common Patterns
常见模式
Pattern 1 — Delete confirmation with icons:
typescript
DialogUtility.confirm({
title: 'Delete Files',
content: 'Permanently delete selected files?',
width: '300px',
okButton: { text: 'Yes', icon: 'e-icons e-check' },
cancelButton: { text: 'No', icon: 'e-icons e-close' }
});Pattern 2 — Alert with close button + ESC support:
typescript
DialogUtility.alert({
title: 'Session Expired',
content: 'Your session has expired. Please log in again.',
width: '300px',
showCloseIcon: true,
closeOnEscape: true
});Pattern 3 — Positioned modal confirm:
typescript
DialogUtility.confirm({
title: 'Confirm Action',
content: 'Submit the form?',
isModal: true,
position: { X: 'center', Y: 'center' },
animationSettings: { effect: 'Zoom' },
isDraggable: true,
width: '280px'
});模式1 — 带图标的删除确认对话框:
typescript
DialogUtility.confirm({
title: 'Delete Files',
content: 'Permanently delete selected files?',
width: '300px',
okButton: { text: 'Yes', icon: 'e-icons e-check' },
cancelButton: { text: 'No', icon: 'e-icons e-close' }
});模式2 — 带关闭按钮和ESC支持的警告对话框:
typescript
DialogUtility.alert({
title: 'Session Expired',
content: 'Your session has expired. Please log in again.',
width: '300px',
showCloseIcon: true,
closeOnEscape: true
});模式3 — 自定义定位的模态确认对话框:
typescript
DialogUtility.confirm({
title: 'Confirm Action',
content: 'Submit the form?',
isModal: true,
position: { X: 'center', Y: 'center' },
animationSettings: { effect: 'Zoom' },
isDraggable: true,
width: '280px'
});Key Properties at a Glance
核心属性速览
| Property | Purpose | Default |
|---|---|---|
| Dialog header text | — |
| Body text or HTML string | — |
| Dialog width (px or %) | |
| Overlay + modal behavior | |
| Allow header drag to reposition | |
| Show × close button | |
| Close on ESC key | |
| | |
| | |
| OK button config | — |
| Cancel button config | — |
| Custom CSS class on dialog root | |
| Stacking order | |
| Callback after dialog opens | — |
| Callback after dialog closes | — |
| 属性 | 用途 | 默认值 |
|---|---|---|
| 对话框头部文本 | — |
| 主体文本或HTML字符串 | — |
| 对话框宽度(px或%) | |
| 遮罩层+模态行为 | |
| 允许通过头部拖拽调整位置 | |
| 显示×关闭按钮 | |
| 按ESC键关闭 | |
| | |
| | |
| 确认按钮配置 | — |
| 取消按钮配置 | — |
| 对话框根元素的自定义CSS类 | |
| 堆叠顺序 | |
| 对话框打开后的回调 | — |
| 对话框关闭后的回调 | — |
Documentation
文档
Getting Started
快速入门
📄 Read: references/getting-started.md
- Installation and package setup
- CSS imports and theme options
- Basic alert, confirm, and prompt examples
- All option properties
DialogUtility
📄 阅读: references/getting-started.md
- 安装与包配置
- CSS导入与主题选项
- 基础警告、确认和提示对话框示例
- 的所有配置属性
DialogUtility
Customization
定制
📄 Read: references/customization.md
- Button text and icon customization
- Show/hide close icon and ESC behavior
- Custom HTML content in dialogs
- Programmatic dialog close with
hide()
📄 阅读: references/customization.md
- 按钮文本与图标定制
- 显示/隐藏关闭按钮与ESC行为设置
- 对话框中的自定义HTML内容
- 使用程序化关闭对话框
hide()
Position and Dimension
定位与尺寸
📄 Read: references/position-and-dimension.md
- Position X/Y values and offset usage
- Width and height properties
- Max-width/max-height via
cssClass - Min-width/min-height via
cssClass
📄 阅读: references/position-and-dimension.md
- X/Y位置值与偏移量用法
- 宽度与高度属性
- 通过设置最大宽度/高度
cssClass - 通过设置最小宽度/高度
cssClass
Animation and Draggable
动画与拖拽
📄 Read: references/animation-and-draggable.md
- effect options (Zoom, Fade, FadeZoom, etc.)
animationSettings - Duration and delay configuration
- for all dialog types
isDraggable
📄 阅读: references/animation-and-draggable.md
- 支持的动画效果(缩放、淡入、淡入缩放等)
animationSettings - 时长与延迟配置
- 所有对话框类型的设置
isDraggable
Events and Patterns
事件与模式
📄 Read: references/events-and-patterns.md
- and
openevent callbacksclose - ,
isModal,zIndexadvanced usagecssClass - Common real-world patterns (delete confirm, form prompt, info alert)
- Managing multiple dialog instances
📄 阅读: references/events-and-patterns.md
- 和
open事件回调close - 、
isModal、zIndex的高级用法cssClass - 常见实际场景(删除确认、表单提示、信息警告)
- 多对话框实例管理
API Reference
API参考
📄 Read: references/api.md
- Complete and
DialogUtility.alert()optionsDialogUtility.confirm() - /
okButtonButtonArgs propertiescancelButton - properties
AnimationSettingsModel - properties
PositionDataModel - properties, methods, and events
DialogComponent
📄 阅读: references/api.md
- 和
DialogUtility.alert()的完整配置选项DialogUtility.confirm() - /
okButton的ButtonArgs属性cancelButton - 属性
AnimationSettingsModel - 属性
PositionDataModel - 的属性、方法与事件
DialogComponent
Tooltip
Tooltip
The Syncfusion Angular Tooltip () displays a pop-up with information or a message when you hover, click, focus, or touch a target element. It supports 12 positions, animations, HTML/template/AJAX content, sticky mode, mouse trailing, and full accessibility compliance.
ejs-tooltipSyncfusion Angular Tooltip()会在用户悬停、点击、聚焦或触摸目标元素时,弹出包含信息或消息的窗口。它支持12种定位方式、动画效果、HTML/模板/AJAX内容、粘性模式、鼠标跟随,且完全符合无障碍标准。
ejs-tooltipNavigation Guide
导航指南
Getting Started
快速入门
📄 Read: references/getting-started.md
- Installation and package setup ()
ng add @syncfusion/ej2-angular-popups - CSS theme imports
- Basic single-target tooltip
- Multi-target tooltip with property
target - Standalone (Angular 19+) and module-based setup
📄 阅读: references/getting-started.md
- 安装与包配置()
ng add @syncfusion/ej2-angular-popups - CSS主题导入
- 基础单目标Tooltip
- 使用属性实现多目标Tooltip
target - 独立组件(Angular 19+)与基于模块的配置
Content
内容
📄 Read: references/content.md
- Static text and HTML string content
- Template content using
ng-template - Dynamic content via AJAX/Fetch in event
beforeRender - Loading HTML elements (iframes, videos) in tooltip
- and
enableHtmlParseoptionsenableHtmlSanitizer
📄 阅读: references/content.md
- 静态文本与HTML字符串内容
- 使用实现模板内容
ng-template - 通过事件加载AJAX/Fetch动态内容
beforeRender - 在Tooltip中加载HTML元素(iframe、视频)
- 和
enableHtmlParse选项enableHtmlSanitizer
Position & Dimensions
定位与尺寸
📄 Read: references/position-and-dimension.md
- All 12 position values (,
TopCenter, etc.)BottomLeft - Tip pointer show/hide and position
- Mouse trailing
- Offset values (,
offsetX)offsetY - Width, height, and scroll mode
- Window collision handling
📄 阅读: references/position-and-dimension.md
- 所有12种定位值(、
TopCenter等)BottomLeft - 提示箭头的显示/隐藏与定位
- 鼠标跟随
- 偏移量设置(、
offsetX)offsetY - 宽度、高度与滚动模式
- 窗口碰撞处理
Open Modes
触发模式
📄 Read: references/open-mode.md
- : Auto, Hover, Click, Focus, Custom
opensOn - Combining multiple open modes
- Custom mode with programmatic /
open()close() - Sticky mode ()
isSticky - Open/close delay
📄 阅读: references/open-mode.md
- :自动、悬停、点击、聚焦、自定义
opensOn - 组合多种触发模式
- 自定义模式下的程序化/
open()close() - 粘性模式()
isSticky - 打开/关闭延迟
Animation
动画
📄 Read: references/animation.md
- property with open/close settings
animation - All supported animation effects
- Applying animations via /
open()methodsclose() - Custom transition effects
📄 阅读: references/animation.md
- 包含打开/关闭设置的属性
animation - 所有支持的动画效果
- 通过/
open()方法应用动画close() - 自定义过渡效果
Customization & Style
定制与样式
📄 Read: references/customization-and-style.md
- for custom styles
cssClass - CSS class reference for tooltip structure
- Tip pointer customization
- Fancy tips (curved, bubble)
- SVG and canvas tooltips
- Tooltips on disabled elements
- Container, RTL, htmlAttributes
📄 阅读: references/customization-and-style.md
- 用于自定义样式的
cssClass - Tooltip结构的CSS类参考
- 提示箭头定制
- 花式提示(弧形、气泡)
- SVG与Canvas Tooltip
- 禁用元素上的Tooltip
- 容器、RTL、htmlAttributes
Accessibility
无障碍支持
📄 Read: references/accessibility.md
- WCAG 2.2, Section 508 compliance
- WAI-ARIA attributes
- Keyboard navigation
- Screen reader support
📄 阅读: references/accessibility.md
- WCAG 2.2、Section 508合规
- WAI-ARIA属性
- 键盘导航
- 屏幕阅读器支持
API Reference
API参考
📄 Read: references/api.md
- All properties, methods, and events
- Type definitions and defaults
- ,
TooltipEventArgs,AnimationModelTooltipAnimationSettings - ,
Position, andTipPointerPositionenumerationsEffect
📄 阅读: references/api.md
- 所有属性、方法与事件
- 类型定义与默认值
- 、
TooltipEventArgs、AnimationModelTooltipAnimationSettings - 、
Position和TipPointerPosition枚举Effect
Quick Start
快速入门
bash
ng add @syncfusion/ej2-angular-popupstypescript
// src/app/app.ts (Angular 19+ standalone)
import { Component, ViewEncapsulation } from '@angular/core';
import { TooltipModule } from '@syncfusion/ej2-angular-popups';
@Component({
standalone: true,
imports: [TooltipModule],
selector: 'app-root',
encapsulation: ViewEncapsulation.None,
template: `
<ejs-tooltip content="Hello, I am a Tooltip!" position="BottomCenter">
<button>Hover me</button>
</ejs-tooltip>
`
})
export class App {}css
/* styles.css */
@import "@syncfusion/ej2-base/styles/material3.css";
@import "@syncfusion/ej2-angular-buttons/styles/material3.css";
@import "@syncfusion/ej2-angular-popups/styles/material3.css";bash
ng add @syncfusion/ej2-angular-popupstypescript
// src/app/app.ts (Angular 19+独立组件)
import { Component, ViewEncapsulation } from '@angular/core';
import { TooltipModule } from '@syncfusion/ej2-angular-popups';
@Component({
standalone: true,
imports: [TooltipModule],
selector: 'app-root',
encapsulation: ViewEncapsulation.None,
template: `
<ejs-tooltip content="Hello, I am a Tooltip!" position="BottomCenter">
<button>Hover me</button>
</ejs-tooltip>
`
})
export class App {}css
/* styles.css */
@import "@syncfusion/ej2-base/styles/material3.css";
@import "@syncfusion/ej2-angular-buttons/styles/material3.css";
@import "@syncfusion/ej2-angular-popups/styles/material3.css";Common Patterns
常见模式
Multi-target tooltip (single instance)
多目标Tooltip(单实例)
html
<!-- Wraps a container; target selector picks which children get tooltips -->
<ejs-tooltip target=".has-tip">
<div id="container">
<button class="has-tip" title="Save your work">Save</button>
<button class="has-tip" title="Delete selected item">Delete</button>
<button>No tooltip here</button>
</div>
</ejs-tooltip>html
<!-- 包裹容器;target选择器指定哪些子元素显示Tooltip -->
<ejs-tooltip target=".has-tip">
<div id="container">
<button class="has-tip" title="Save your work">Save</button>
<button class="has-tip" title="Delete selected item">Delete</button>
<button>No tooltip here</button>
</div>
</ejs-tooltip>Tooltip that opens on click
点击触发的Tooltip
html
<ejs-tooltip content="Clicked!" opensOn="Click" position="RightCenter">
<button>Click me</button>
</ejs-tooltip>html
<ejs-tooltip content="Clicked!" opensOn="Click" position="RightCenter">
<button>Click me</button>
</ejs-tooltip>Sticky tooltip with close button
带关闭按钮的粘性Tooltip
html
<ejs-tooltip content="I stay until you close me." [isSticky]="true">
<span>Hover and pin me</span>
</ejs-tooltip>html
<ejs-tooltip content="I stay until you close me." [isSticky]="true">
<span>Hover and pin me</span>
</ejs-tooltip>HTML content tooltip
HTML内容Tooltip
typescript
public htmlContent: string = '<b>Bold</b> and <i>italic</i> text with a <a href="#">link</a>.';html
<ejs-tooltip [content]="htmlContent">
<button>Rich content</button>
</ejs-tooltip>typescript
public htmlContent: string = '<b>Bold</b> and <i>italic</i> text with a <a href="#">link</a>.';html
<ejs-tooltip [content]="htmlContent">
<button>Rich content</button>
</ejs-tooltip>Programmatic open/close (custom mode)
程序化打开/关闭(自定义模式)
typescript
@ViewChild('tooltip') tooltip!: TooltipComponent;
openTip(): void {
this.tooltip.open(this.tooltip.element);
}
closeTip(): void {
this.tooltip.close();
}html
<ejs-tooltip #tooltip content="Custom trigger" opensOn="Custom">
<span>Target</span>
</ejs-tooltip>
<button (click)="openTip()">Show</button>
<button (click)="closeTip()">Hide</button>typescript
@ViewChild('tooltip') tooltip!: TooltipComponent;
openTip(): void {
this.tooltip.open(this.tooltip.element);
}
closeTip(): void {
this.tooltip.close();
}html
<ejs-tooltip #tooltip content="Custom trigger" opensOn="Custom">
<span>Target</span>
</ejs-tooltip>
<button (click)="openTip()">Show</button>
<button (click)="closeTip()">Hide</button>Key Properties at a Glance
核心属性速览
| Property | Type | Default | Purpose |
|---|---|---|---|
| | — | Tooltip content |
| | | Where tooltip appears |
| | | Trigger: Auto/Hover/Click/Focus/Custom |
| | | Keep open until manually closed |
| | | Follow mouse pointer |
| | | Delay (ms) before opening |
| | | Delay (ms) before closing |
| | FadeIn/FadeOut 150ms | Open/close animation |
| | — | Selector for multi-target |
| | | Custom CSS class |
| | | Show/hide arrow tip |
| | | Dimensions |
For full property, method, and event reference, read references/api.md.
| 属性 | 类型 | 默认值 | 用途 |
|---|---|---|---|
| | — | Tooltip内容 |
| | | Tooltip显示位置 |
| | | 触发方式:自动/悬停/点击/聚焦/自定义 |
| | | 保持打开状态直到手动关闭 |
| | | 跟随鼠标指针移动 |
| | | 打开延迟(毫秒) |
| | | 关闭延迟(毫秒) |
| | 淡入/淡出 150ms | 打开/关闭动画 |
| | — | 多目标选择器 |
| | | 自定义CSS类 |
| | | 显示/隐藏箭头提示 |
| | | 尺寸设置 |
如需完整的属性、方法与事件参考,请阅读references/api.md。