技能 angular-ui-patterns
📦

angular-ui-patterns

安全

使用經驗證的模式打造穩健的 Angular UI

建立可靠的 Angular 介面需要一致地處理載入狀態、錯誤與空白狀態。本技能提供久經實戰驗證的模式,確保使用者始終了解你的應用程式正在發生什麼。

支援: Claude Codex Code(CC)
🥉 75 青銅
1

下載技能 ZIP

2

在 Claude 中上傳

前往 設定 → 功能 → 技能 → 上傳技能

3

開啟並開始使用

測試它

正在使用「angular-ui-patterns」。 A component that fetches and displays user posts

預期結果:

  • 元件在初次載入時顯示骨架載入器(尚無資料)
  • 資料到達但為空時,顯示空白狀態與「Create Post」按鈕
  • API 回傳錯誤時,在保留快取資料可見的同時顯示可重試的錯誤提示
  • 成功載入後,渲染完整貼文清單並具備正確的無障礙屬性

正在使用「angular-ui-patterns」。 A save button in a settings form

預期結果:

  • 按鈕僅在表單有效時可用
  • 點擊後按鈕停用並顯示帶有「Saving...」文字的旋轉指示
  • 成功時顯示綠色勾號與「Saved!」,2 秒後回復
  • 失敗時顯示紅色 X 與錯誤訊息,並重新啟用按鈕以便重試

安全審計

安全
v1 • 2/24/2026

Documentation-only skill containing Angular UI pattern guidance. All 63 static analysis findings are false positives: URLs are documentation references (not network calls), backticks are markdown code fencing (not shell execution), and crypto detections are text pattern misidentifications. No executable code, network requests, or command execution present.

3
已掃描檔案
581
分析行數
0
發現項
1
審計總數
未發現安全問題
審計者: claude

品質評分

38
架構
100
可維護性
87
內容
50
社群
100
安全
96
規範符合性

你能建構什麼

打造資料驅動儀表板的前端開發者

在從多個 API 擷取資料且延遲不一的儀表板元件中,實作一致的載入、錯誤與空白狀態。

建立 UI 標準的團隊主管

定義全組織的狀態管理、錯誤處理與使用者回饋模式,確保跨團隊一致的使用者體驗。

生成 Angular 元件的 AI 助手

引導 Claude 或 Codex 產生遵循已驗證狀態處理模式的 Angular 元件,避免常見陷阱,例如無聲錯誤或缺少載入狀態。

試試這些提示

基本載入狀態模式
Create an Angular component that displays a list of items. Show a skeleton loader when loading with no data, an empty state when the list is empty, an error state with retry when loading fails, and the actual data when available. Use Angular Signals and modern control flow.
包含驗證與提交狀態的表單
Build an Angular form component with reactive forms validation. Show inline error messages for invalid fields, disable the submit button during form submission, display a loading indicator on the button, and show success or error toast notifications after the async operation completes.
使用 @defer 的漸進式內容載入
Implement an Angular page that loads critical content immediately and defers non-critical sections like comments, related items, or analytics using @defer. Include placeholder, loading, and error states for each deferred block with appropriate minimum loading times.
具樂觀更新的確認對話框
Create a delete confirmation dialog pattern that shows a modal asking for confirmation, applies optimistic UI updates when confirmed, rolls back changes if the server request fails, and displays appropriate feedback to the user throughout the process.

最佳實務

  • 務必向使用者顯示錯誤—不要在沒有回饋的情況下悄悄捕捉例外
  • 只有在沒有既有資料時才顯示載入指示,以避免內容閃爍
  • 在非同步操作期間停用動作按鈕,防止重複提交

避免

  • 在已有快取資料時仍顯示 spinner—會在重新取得資料時造成不必要的視覺閃爍
  • 在 catch 區塊吞掉錯誤而未告知使用者失敗
  • 未在處理期間停用而允許提交按鈕被快速連點

常見問題

我何時應該使用骨架載入器而不是 spinner?
初次載入頁面與清單版面在內容形狀已知時使用骨架載入器。當內容形狀未知或區域很小時,例如彈窗操作、按鈕提交與內嵌操作,使用 spinner。
當我有部分資料可用時,該如何處理錯誤?
顯示既有資料,並在受影響區段的上方或下方顯示錯誤提示。這種優雅降級的做法能讓 UI 保持可用,同時告知使用者部分失敗。
spinner 的最短載入時間是多少?
載入狀態最少維持 200ms 以避免閃爍。若操作在 200ms 內完成,仍應顯示完整載入時長,以避免突兀的視覺轉換。
我應該如何處理表單驗證錯誤?
僅在使用者觸碰過欄位後,於欄位旁以內嵌方式顯示驗證錯誤。使用清楚、可行動的訊息,說明哪裡有問題以及如何修正。
我何時應該使用樂觀更新?
對於可接受回復的非關鍵操作使用樂觀更新,例如按讚、追蹤或非破壞性編輯。務必實作回復邏輯,以防伺服器請求失敗。
我該如何讓載入狀態具備無障礙性?
使用 aria-live 區域向螢幕閱讀器宣布載入狀態變化。確保狀態變更後妥善管理焦點,並為視覺載入指示提供文字替代。

開發者詳情

檔案結構