Angular开发指南_angular-developer
以下为本文档的中文说明angular-developer 是 Angular 官方团队提供的 Angular 代码生成与架构指导技能为 Angular 开发者提供了全面的最佳实践参考。该技能涵盖了 Angular 开发的各个关键领域信号Signals响应式编程包括 linkedSignal 和 resource 等新 API 的正确使用表单处理涵盖模板驱动表单和响应式表单的最佳实践依赖注入包括 provide 函数、注入上下文和层级注入器路由配置包括懒加载、路由守卫和路由解析器服务端渲染SSR的支持无障碍性ARIA的实践指南动画系统的使用组件样式方案包括组件样式封装和 Tailwind CSS 的集成自动化测试包括单元测试和端到端测试的策略以及 Angular CLI 工具链的高效使用。使用场景包括新建 Angular 项目时的架构决策、为现有项目添加新组件或服务、优化应用性能、重构遗留代码、以及解决在开发过程中遇到的具体技术问题。核心原则是在给出任何建议之前先分析项目的 Angular 版本——不同版本之间的最佳实践和可用特性差异很大例如 Angular 17 引入的信号系统在 Angular 16 中并不存在。每当生成代码后技能要求运行 ng build 确保没有构建错误这体现了质量至上的工程理念。该技能遵循 Angular 官方风格指南确保生成的代码在可维护性和性能方面达到生产级标准。Angular Developer GuidelinesAlways analyze the project’s Angular version before providing guidance, as best practices and available features can vary significantly between versions. If creating a new project with Angular CLI, do not specify a version unless prompted by the user.When generating code, follow Angular’s style guide and best practices for maintainability and performance. Use the Angular CLI for scaffolding components, services, directives, pipes, and routes to ensure consistency.Once you finish generating code, runng buildto ensure there are no build errors. If there are errors, analyze the error messages and fix them before proceeding. Do not skip this step, as it is critical for ensuring the generated code is correct and functional.Creating New ProjectsIf no guidelines are provided by the user, here are same default rules to follow when creating a new Angular project:Use the latest stable version of Angular unless the user specifies otherwise.Use Signals Forms for form management in new projects (available in Angular v21 and newer) Find out more.Execution Rules forng new:When asked to create a new Angular project, you must determine the correct execution command by following these strict steps:Step 1: Check for an explicit user version.IFthe user requests a specific version (e.g., Angular 15), bypass local installations and strictly usenpx.Command:npx angular/clirequested_version new project-nameStep 2: Check for an existing Angular installation.IFno specific version is requested, runng versionin the terminal to check if the Angular CLI is already installed on the system.IFthe command succeeds and returns an installed version, use the local/global installation directly.Command:ng new project-nameStep 3: Fallback to Latest.IFno specific version is requested AND theng versioncommand fails (indicating no Angular installation exists), you must usenpxto fetch the latest version.Command:npx angular/clilatest new project-nameComponentsWhen working with Angular components, consult the following references based on the task:Fundamentals: Anatomy, metadata, core concepts, and template control flow (if, for, switch). Read components.mdInputs: Signal-based inputs, transforms, and model inputs. Read inputs.mdOutputs: Signal-based outputs and custom event best practices. Read outputs.mdHost Elements: Host bindings and attribute injection. Read host-elements.mdIf you require deeper documentation not found in the references above, read the documentation athttps://angular.dev/guide/components.Reactivity and Data ManagementWhen managing state and data reactivity, use Angular Signals and consult the following references:Signals Overview: Core signal concepts (signal,computed), reactive contexts, anduntracked. Read signals-overview.mdDependent State (linkedSignal): Creating writable state linked to source signals. Read linked-signal.mdAsync Reactivity (resource): Fetching asynchronous data directly into signal state. Read resource.mdSide Effects (effect): Logging, third-party DOM manipulation (afterRenderEffect), and when NOT to use effects. Read effects.mdFormsIn most cases for new apps,prefer signal forms. When making a forms decision, analyze the project and consider the following guidelines:if the application is using v21 or newer and this is a new form,prefer signal forms.-For older applications or when working with existing forms, use the appropriate form type that matches the applications current form strategy.Signal Forms: Use signals for form state management. Read [signal-forms.md](references/signal-forms.md)Template-driven forms: Use for simple forms. Read template-driven-forms.mdReactive forms: Use for complex forms. Read reactive-forms.mdDependency InjectionWhen implementing dependency injection in Angular, follow these guidelines:Fundamentals: Overview of Dependency Injection, services, and theinject()function. Read di-fundamentals.mdCreating and Using Services: Creating services, theprovidedIn: rootoption, and injecting into components or other services. Read creating-services.mdDefining Dependency Providers: Automatic vs manual provision,InjectionToken,useClass,useValue,useFactory, and scopes. Read defining-providers.mdInjection Context: Whereinject()is allowed,runInInjectionContext, andassertInInjectionContext. Read injection-context.mdHierarchical Injectors: TheEnvironmentInjectorvsElementInjector, resolution rules, modifiers (optional,skipSelf), andprovidersvsviewProviders. Read hierarchical-injectors.mdAngular AriaWhen building accessible custom components for any of the following patterns: Accordion, Listbox, Combobox, Menu, Tabs, Toolbar, Tree, Grid, consult the following reference:Angular Aria Components: Building headless, accessible components (Accordion, Listbox, Combobox, Menu, Tabs, Toolbar, Tree, Grid) and styling ARIA attributes. Read angular-aria.mdRoutingWhen implementing navigation in Angular, consult the following references:Define Routes: URL paths, static vs dynamic segments, wildcards, and redirects. Read define-routes.mdRoute Loading Strategies: Eager vs lazy loading, and context-aware loading. Read loading-strategies.mdShow Routes with Outlets: Usingrouter-outlet, nested outlets, and named outlets. Read show-routes-with-outlets.mdNavigate to Routes: Declarative navigation withRouterLinkand programmatic navigation withRouter. Read navigate-to-routes.mdControl Route Access with Guards: ImplementingCanActivate,CanMatch, and other guards for security. Read route-guards.mdData Resolvers: Pre-fetching data before route activation withResolveFn. Read>Styling and AnimationsWhen implementing styling and animations in Angular, consult the following references:Using Tailwind CSS with Angular: Integrating Tailwind CSS into Angular projects. Read tailwind-css.mdAngular Animations: Using native CSS (recommended) or the legacy DSL for dynamic effects. Read angular-animations.mdStyling components: Best practices for component styles and encapsulation. Read component-styling.mdTestingWhen writing or updating tests, consult the following references based on the task:Fundamentals: Best practices for unit testing (Vitest), async patterns, andTestBed. Read [testing-fundamentals.md](references/testing-fundamentals.md)Component Harnesses: Standard patterns for robust component interaction. Read component-harnesses.mdRouter Testing: UsingRouterTestingHarnessfor reliable navigation tests. Read router-testing.mdEnd-to-End (E2E) Testing: Best practices for E2E tests with Cypress. Read e2e-testing.mdToolingWhen working with Angular tooling, consult the following references:Angular CLI: Creating applications, generating code (components, routes, services), serving, and building. Read cli.mdCode Modernization: Automatically refactoring to modern standards using migrations. Read migrations.mdAngular MCP Server: Available tools, configuration, and experimental features. Read mcp.md3e:[“ , ,,L41”,null,{“content”:“$42”,“frontMatter”:{“name”:“angular-developer”,“description”:“Generates Angular code and provides architectural guidance. Trigger when creating projects, components, or services, or for best practices on reactivity (signals, linkedSignal, resource), forms, dependency injection, routing, SSR, accessibility (ARIA), animations, styling (component styles, Tailwind CSS), testing, or CLI tooling.”,“license”:“MIT”,“metadata”:{“author”:“Copyright 2026 Google LLC”,“version”:“1.0”}}}]3f:[“KaTeX parse error: Expected }, got EOF at end of input: …,children:[[”,“div”,null,{“className”:“flex items-center justify-between border-b border-border bg-muted/30 px-4 py-2.5”,“children”:[[“KaTeX parse error: Expected }, got EOF at end of input: …,children:[”,“span”,null,{“className”:“truncate text-xs font-medium text-muted-foreground”,“children”:“同仓库更多 Skills”}]}],[“KaTeX parse error: Expected EOF, got } at position 88: …ldren:同仓库}]]}̲],[”,“div”,null,{“className”:“p-4 sm:p-5”,“children”:[[“ , h 2 , n u l l , i d : r e l a t e d − s k i l l s − h e a d i n g , c l a s s N a m e : t e x t − 2 x l f o n t − s e m i b o l d t r a c k i n g − n o r m a l t e x t − f o r e g r o u n d , c h i l d r e n : 同仓库更多 S k i l l s ] , [ ,h2,null,{id:related-skills-heading,className:text-2xl font-semibold tracking-normal text-foreground,children:同仓库更多 Skills}],[,h2,null,id:related−skills−heading,className:text−2xlfont−semiboldtracking−normaltext−foreground,children:同仓库更多Skills],[”,“div”,null,{“className”:“mt-4 grid gap-3 sm:grid-cols-2”,“children”:[“L 43 , L43,L43,L44”,“$L45”]}]]}]]}]46:I[206516,[“/_next/static/chunks/051aanbhrv4br.js”,“/_next/static/chunks/0mizr60h7ayzt.js”,“/_next/static/chunks/0v9lm1dmbdoo-.js”,“/_next/static/chunks/0rxr1j1j3j-.r.js”,“/_next/static/chunks/02ftybezfvqjd.js”,“/_next/static/chunks/0.v9ksvnnj8ia.js”,“/_next/static/chunks/0bn6id96nx3k.js,“/_next/static/chunks/13ybnhn37c.tc.js”,“/_next/static/chunks/0_fnrdtruz8uf.js”,“/_next/static/chunks/0r6l15utt1mwb.js”,“/_next/static/chunks/0dm9a5into854.js”,/_next/static/chunks/07k6hqoibtcn.js”,“/next/static/chunks/0b4cao.4y…j.js”,“/_next/static/chunks/02i-n28z7kjd0.js”],“default”]

相关新闻

【湿法-萃取工艺20】---MSP废水处-四大核心技术深度细化

【湿法-萃取工艺20】---MSP废水处-四大核心技术深度细化

镁系废水(硫酸镁)资源化系统 —— 四大核心技术深度细化 以下对树脂选型对比表、MVR能耗计算、解析液萃取工艺、硫酸镁结晶工艺参数进行系统性、工程级别的细化。 一、树脂选型对比表(针对镁系废水Ni/Co/Mg分离) 1.1 选型核心原…

2026/7/24 22:10:53阅读更多 →
国际首都公报:放飞炬人集团行政总裁方达炬批准《集团国际财务责任001001支柱上项目产品的制成、上市、经济司法制度的应税价格》

国际首都公报:放飞炬人集团行政总裁方达炬批准《集团国际财务责任001001支柱上项目产品的制成、上市、经济司法制度的应税价格》

国际首都公报:放飞炬人集团行政总裁方达炬批准《集团国际财务责任001001支柱上项目产品的制成、上市、经济司法制度的应税价格》

2026/7/24 22:10:53阅读更多 →
Claude Code高级提示词工程全解|全网独家分层模板复现 结构化指令规范进阶技巧赋能全场景工程开发、企业级项目落地提效

Claude Code高级提示词工程全解|全网独家分层模板复现 结构化指令规范进阶技巧赋能全场景工程开发、企业级项目落地提效

目录 一、前言:提示词工程决定Claude Code开发上限 二、Claude Code底层核心:分层式系统提示架构深度解析 2.1 八大分层架构核心机制详解 2.2 工程级提示词核心设计思想 三、四大核心高级提示技巧(工程提效核心、全场景适配) 3.1 XML结构化分层提示(复杂多模块开发首…

2026/7/24 22:10:53阅读更多 →
RAG系统文档分块策略与优化实践

RAG系统文档分块策略与优化实践

1. 为什么文档分块是RAG系统的命门?上周帮朋友排查一个RAG系统的问题,他们的医疗问答机器人总把"糖尿病治疗方案"回答成"妊娠期饮食建议"。当我打开原始文档才恍然大悟——300页的PDF被粗暴地按固定字符数切割,导致关键医…

2026/7/25 2:11:39阅读更多 →
网盘直链下载助手:一站式解锁九大网盘高速下载的智能解决方案

网盘直链下载助手:一站式解锁九大网盘高速下载的智能解决方案

网盘直链下载助手:一站式解锁九大网盘高速下载的智能解决方案 【免费下载链接】Online-disk-direct-link-download-assistant 一个基于 JavaScript 的网盘文件下载地址获取工具。基于【网盘直链下载助手】修改 ,支持 百度网盘 / 阿里云盘 / 中国移动云盘…

2026/7/25 2:11:39阅读更多 →
企业AI私有化部署的五大核心考量与实战经验

企业AI私有化部署的五大核心考量与实战经验

1. 企业AI私有化部署的核心考量去年给某制造业客户做AI质检方案时,他们CIO的一句话让我印象深刻:"上AI系统就像结婚,选型失误的离婚成本比谈恋爱高十倍。"这句话道破了企业AI私有化部署的关键——前期选型直接决定后期成败。作为实…

2026/7/25 2:11:35阅读更多 →
一次多模态项目从 0 到 1 的全程记录:三个月踩过的坑

一次多模态项目从 0 到 1 的全程记录:三个月踩过的坑

一次多模态项目从 0 到 1 的全程记录:三个月踩过的坑 一、个性化深度引言 这个项目启动于今年初,目标是为某客户做一个"图文商品属性自动提取"系统——上传电商商品图片,系统自动识别品类、品牌、规格参数,填入ERP系统。…

2026/7/25 2:11:34阅读更多 →
AI Agent如何实现全链路自动化营销

AI Agent如何实现全链路自动化营销

1. AI Agent如何真正成为营销领域的"超级员工"最近行业里关于"AI超级员工"的讨论越来越热,但真正能落地执行全流程营销任务的AI Agent并不多见。创客兔团队经过两年多的实战验证,确实打造出了一套能够真正"动手干活"的自动…

2026/7/25 2:11:34阅读更多 →
计算机毕业设计之基于Node.js+Vue的在线音乐播放系统的设计与实现

计算机毕业设计之基于Node.js+Vue的在线音乐播放系统的设计与实现

随着新经济的需求和新技术的发展,特别是网络技术的发展,如果可以建立起在线音乐播放系统,可以改变传统线下管理方式,在过去的时代里都使用传统的方式实行,既花费了时间,又浪费了精力。在信息如此发达的今天…

2026/7/25 2:09:34阅读更多 →
Go语言静态资源打包方案对比与实践指南

Go语言静态资源打包方案对比与实践指南

1. 项目背景与核心需求在Go语言开发中,我们经常需要处理静态资源文件的打包问题。无论是Web应用的模板文件、前端资源,还是配置文件、证书等,都需要随程序一起分发。传统做法是将这些文件与编译后的二进制文件放在同一目录下,但这…

2026/7/25 1:01:14阅读更多 →
Go语言实现高性能LDAP认证服务的架构与实践

Go语言实现高性能LDAP认证服务的架构与实践

1. 项目背景与核心价值LDAP(轻量级目录访问协议)作为企业级身份认证的黄金标准,已经服务了超过80%的财富500强公司。我在金融科技领域实施统一认证体系时,发现传统Java方案存在启动慢、内存占用高等痛点。而Go语言凭借其协程并发模…

2026/7/25 1:01:14阅读更多 →
【AI面试官实战指南】:用ChatGPT模拟10类高频技术岗面试,3天提升应答精准度92%

【AI面试官实战指南】:用ChatGPT模拟10类高频技术岗面试,3天提升应答精准度92%

更多请点击: https://intelliparadigm.com 第一章:AI面试官实战指南的核心价值与适用场景 AI面试官并非替代人类HR的“黑箱工具”,而是以可解释、可审计、可迭代的方式,赋能招聘全链路的关键基础设施。其核心价值在于将主观经验沉…

2026/7/25 1:01:14阅读更多 →
突破文档下载限制:kill-doc让你看到的都能保存

突破文档下载限制:kill-doc让你看到的都能保存

突破文档下载限制:kill-doc让你看到的都能保存 【免费下载链接】kill-doc 看到经常有小伙伴们需要下载一些免费文档,但是相关网站浏览体验不好各种广告,各种登录验证,需要很多步骤才能下载文档,该脚本就是为了解决您的…

2026/7/25 0:01:16阅读更多 →
C++ string类模拟实现:从深拷贝到内存管理的完整指南

C++ string类模拟实现:从深拷贝到内存管理的完整指南

1. 项目概述:为什么我们要“手撕”string类?在C的学习道路上,尤其是从C语言过渡到C的“初阶”阶段,string类绝对是一个绕不开的核心。标准库里的std::string用起来太方便了,、find、substr,几个操作符和函数…

2026/7/25 0:01:16阅读更多 →
三角洲寻宝鼠工具:高效文件搜索与资源管理实战指南

三角洲寻宝鼠工具:高效文件搜索与资源管理实战指南

1. 先搞清楚“三角洲寻宝鼠”到底是什么工具从名称来看,“三角洲寻宝鼠”更像是一个资源查找或文件检索类工具,而不是游戏或娱乐软件。这类工具的核心价值在于帮助用户快速定位特定资源,比如文档、图片、压缩包或特定格式的文件。如果你经常需…

2026/7/25 0:01:16阅读更多 →
YOLOv8推理性能优化:从1.2FPS到35FPS的全链路加速实践

YOLOv8推理性能优化:从1.2FPS到35FPS的全链路加速实践

如果你在部署 YOLOv8 时,发现推理速度只有可怜的 1-2 FPS,而别人的演示视频却能跑到 30 FPS 以上,那么问题很可能不在模型本身,而在于你的整个处理链路。很多开发者拿到一个训练好的 YOLOv8 模型后,会直接使用官方示例…

2026/7/24 23:01:03阅读更多 →
Coze与Dify对比指南:低代码AI应用开发从入门到实战

Coze与Dify对比指南:低代码AI应用开发从入门到实战

1. 从零到一:为什么你需要了解 Coze 和 Dify?如果你对 AI 应用开发感兴趣,但一看到“大模型”、“智能体”、“工作流”这些词就头疼,觉得门槛太高,那这篇文章就是为你准备的。很多开发者,包括我自己&#…

2026/7/24 19:00:40阅读更多 →
AI生图工具怎么选?2026年6月版实测对比

AI生图工具怎么选?2026年6月版实测对比

做自媒体的朋友应该都有体会:配图一直是个让人头疼的问题。2026年,AI生图工具已经非常成熟了,但工具太多反而不知道怎么选。以下是截至2026年6月我对主流AI生图工具的实测对比。Midjourney V8.1:速度之王2026年6月11日&#xff0c…

2026/7/24 19:00:40阅读更多 →