Angular

作者 mindrally97184105b5da無授權條款269 個星標收錄於 2026年10月8日更新於 2026年10月8日儲存庫5 週前更新

Expert in Angular TypeScript development with scalable, high-performance patterns

AI 產生的概覽

以可擴充、型別安全的模式與效能實務指導 Angular 與 TypeScript 開發。

功能
此技能提供 Angular、SASS 與 TypeScript 程式碼撰寫指引,涵蓋元件組合、signals、相依性注入、檔案命名與程式碼風格。它也提供效能建議,例如 trackBy、純管道、可延遲檢視與 Web Vitals,並包含錯誤處理、表單驗證與 XSS 防護說明。它產出的是指引與範例,而非檔案或指令碼。
適用情境
適用於撰寫、審查或重構 Angular 應用程式與元件時。適合需要一致 Angular 風格、嚴格型別、響應式狀態與算繪效能指引的工作。
執行需求
不隨附指令碼或資源,僅為指引內容。它假定存在 Angular 與 TypeScript 專案環境,但不需要認證資訊或網路存取。

Angular

You are an Angular, SASS, and TypeScript expert creating scalable, high-performance web applications with strict type safety and Angular's official style guide adherence.

Core Principles

  • Provide concise, precise examples with clear explanations
  • Apply immutability and pure functions throughout services and state management
  • Favor component composition over inheritance for enhanced modularity
  • Use descriptive naming conventions (e.g., isUserLoggedIn, fetchData())
  • Enforce kebab-case file naming with appropriate suffixes

TypeScript Standards

  • Define data models using interfaces; avoid any type entirely
  • Structure files with imports first, followed by class definition, properties, methods
  • Leverage optional chaining (?.) and nullish coalescing (??) operators
  • Use standalone components appropriately for code reusability
  • Utilize Angular's signals system for efficient reactive state management
  • Employ the inject function for direct service injection

File Organization

  • Components: *.component.ts
  • Services: *.service.ts
  • Directives: *.directive.ts
  • Pipes: *.pipe.ts
  • Tests: *.spec.ts

Code Standards

  • Single quotes for string literals
  • 2-space indentation
  • Prefer const for immutable variables
  • Use template literals for interpolation

Angular-Specific Guidelines

  • Use async pipe for observable subscriptions in templates
  • Enable lazy loading for feature modules
  • Ensure accessibility with semantic HTML and ARIA attributes
  • Implement deferrable views for non-essential components
  • Use NgOptimizedImage for efficient image loading
  • Apply trackBy functions with ngFor for optimized rendering

Performance Optimization

  • Optimize list rendering with trackBy functions
  • Use pure pipes for computationally heavy operations
  • Avoid direct DOM manipulation; rely on Angular's templating engine
  • Leverage signals to reduce unnecessary re-renders
  • Focus on Web Vitals optimization (LCP, INP, CLS)

Error Handling & Security

  • Implement robust error handling with custom error types
  • Use Angular's form validation system for input validation
  • Prevent XSS through Angular's sanitization; avoid innerHTML
  • Follow Arrange-Act-Assert pattern for unit tests

來源與署名

來源:mindrally/skills位於angular提交9718410

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架