| 123456789101112131415161718192021222324252627 |
- <button
- [type]="type()"
- [class]="classes()"
- [disabled]="disabled() || loading()"
- [attr.aria-busy]="loading() || null"
- [attr.aria-label]="ariaLabel() || (loading() ? '加载中' : null)"
- >
- <!--
- 🔴 [attr.aria-label] 的「加载中」兜底:加载态把内容整块换成 aria-hidden 的 spinner,
- 按钮就没有可访问名了(WAI-ARIA:aria-busy 不改变名字,disabled 也不会被读屏跳过)。
- 用属性块而非 `[attr.aria-busy]` 行内注释 —— 标签内的 HTML 注释会被当作属性解析,构建报 NG5002。
- -->
- @if (loading()) {
- <i class="fa-solid fa-spinner animate-spin" aria-hidden="true"></i>
- @if (loadingText()) {
- <span>{{ loadingText() }}</span>
- }
- } @else {
- @if (icon()) {
- <i [class]="icon()" aria-hidden="true"></i>
- }
- <ng-content />
- @if (iconRight()) {
- <i [class]="iconRight()" aria-hidden="true"></i>
- }
- }
- </button>
|