跳到主要内容
哒哒星球DADA PLANET

Skill · 已公开版本

angular-state-management · Angular状态管理方案选型与实现

提供Angular应用状态管理的决策框架与代码模式,涵盖Signals、NgRx SignalStore、NgRx Store、ComponentStore及迁移路径。

先看看示例

作者提供的示例,实际效果取决于你的输入和使用工具。

输入

为电商Angular应用设计购物车状态管理,选择Signal服务还是NgRx Store,并给出实现代码。

输出

预期交付:状态方案选型建议、各模式完整代码示例、迁移步骤与最佳实践清单。(编辑说明,非实际运行结果)

方法说明

---
name: angular-state-management
description: "Master modern Angular state management with Signals, NgRx, and RxJS. Use when setting up global state, managing component stores, choosing between state solutions, or migrating from legacy patterns."
risk: safe
source: self
date_added: "2026-02-27"
---

# Angular State Management

Comprehensive guide to modern Angular state management patterns, from Signal-based local state to global stores and server state synchronization.

## Detailed Guide

Read [the detailed guide](references/detailed-guide.md) before executing this skill. It retains the complete procedure and reference material. Treat its safety, prerequisites, and validation requirements as mandatory. For focused work, load the relevant sections; for end-to-end work, read the guide completely.

## When to Use This Skill

- Setting up global state management in Angular
- Choosing between Signals, NgRx, or Akita
- Managing component-level stores
- Implementing optimistic updates
- Debugging state-related issues
- Migrating from legacy state patterns

## Do Not Use This Skill When

- The task is unrelated to Angular state management
- You need React state management → use `react-state-management`

---

## Limitations
- Use this skill only when the task clearly matches the scope described above.
- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.

## Example

For a shared cart counter, use a private writable signal and a public read-only
signal. For remote cart writes, keep authorization on the server and test two
overlapping updates before adding optimistic rollback.