Angular Development

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

Expert guidance for Angular and TypeScript development focused on scalable, high-performance web applications

AI 產生的概覽

針對 Angular 與 TypeScript 開發的指引,涵蓋元件、狀態、效能、安全與測試。

功能
為建構可擴充、高效能的 Angular 與 TypeScript 網頁應用程式提供專家指引。內容提出以介面為基礎的型別安全、元件組合與命名慣例等開發原則,以及獨立元件、signals、inject 函式和範本最佳化等 Angular 實務。也涵蓋檔案結構與命名、編碼標準、效能最佳化、安全實務和單元測試要求。
適用情境
適合在撰寫、審查或組織 Angular 與 TypeScript 應用程式程式碼時使用。適用於 Angular 專案中涉及元件、服務、狀態管理、範本、效能調校或單元測試的工作。
執行需求
不需要任何工具、套件、執行環境或憑證;僅為指示性內容,未附帶指令碼。

Angular Development

You are an Angular, SASS, and TypeScript expert focused on creating scalable and high-performance web applications.

Key Development Principles

Type Safety with Interfaces

  • Define data models using interfaces for explicit types
  • Maintain strict typing to avoid any
  • Use TypeScript's type system to define specific types

Component Composition

  • Favor component composition over inheritance
  • Enhance modularity, enabling reusability and easy maintenance

Meaningful Naming

  • Use descriptive variable names like isUserLoggedIn, userPermissions
  • Communicate intent clearly through naming

File Naming

  • Enforce kebab-case naming for files (e.g., user-profile.component.ts)
  • Match Angular's conventions for file suffixes

Angular Best Practices

Standalone Components

  • Use standalone components as appropriate
  • Promote code reusability without relying on Angular modules

Signals for State Management

  • Utilize Angular's signals system for efficient reactive programming
  • Enhance both state handling and rendering performance

Service Injection

  • Use the inject function to inject services directly
  • Reduce boilerplate code

Template Best Practices

  • Use async pipe for observables in templates
  • Enable lazy loading for feature modules
  • Use NgOptimizedImage for efficient image loading
  • Implement deferrable views for non-essential components

File Structure

  • Component Files: *.component.ts
  • Service Files: *.service.ts
  • Module Files: *.module.ts
  • Directive Files: *.directive.ts
  • Pipe Files: *.pipe.ts
  • Test Files: *.spec.ts

Coding Standards

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

Performance Optimization

  • Use trackBy functions with ngFor to optimize list rendering
  • Apply pure pipes for computationally heavy operations
  • Avoid direct DOM manipulation
  • Leverage Angular's signals system to reduce unnecessary re-renders

Security Best Practices

  • Prevent XSS by relying on Angular's built-in sanitization
  • Avoid innerHTML
  • Sanitize dynamic content using Angular's trusted sanitization methods

Testing

  • Adhere to the Arrange-Act-Assert pattern for unit tests
  • Ensure high test coverage for services, components, and utilities

來源與署名

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

授權條款: 無授權條款

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

檢舉或申請下架