首页/新闻资讯/正文详情

Angular开发指南_angular-developer

发布时间:2026/11/27 17:54:47 来源:云帆数科 栏目:资讯中心
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”]

相关推荐

《设计EDA 候选人跳槽竞业风险简易自测问卷》
《设计EDA 候选人跳槽竞业风险简易自测问卷》

适用人群:设计 EDA 赛道全体人员(工程师 / 组长 / 专家 / 经理 / 总监 / VP/CTO) 使用场景:候选人自我风险评估、猎头初筛、HR 面试前置风险摸底 填写说明:逐项如实勾选,依据最终风险等级判断 offer 可行性;问卷仅作风险参考,不构成法律意见,重大争议建议咨询劳动 / 知… · 2026/11/24 20:33:04

学术论文评审_academic-paper-review
学术论文评审_academic-paper-review

以下为本文档的中文说明Academic Paper Review 是一个专业的学术论文评审技能,能够自动生成结构化的、达到顶级同行评审质量标准的论文深度分析报告。该技能严格模仿顶级学术会议和期刊的评审标准,包括 NeurIPS、ICML、ACL、Nature 和 IEEE 等&#xff0… · 2026/11/28 3:48:00

系统配置仪表板_diverga
系统配置仪表板_diverga

以下为本文档的中文说明该技能用于Diverga仪表板——提供实时的配置状态和功能概览。Diverga是一个系统管理平台,此技能帮助用户快速查看系统的运行配置、功能开关状态和关键性能指标。它提供了一目了然的可视化仪表板,整合分散的系统信息于统一的视图之… · 2026/9/15 5:22:37

柳州电工证在哪里年审电子证书怎么查
柳州电工证在哪里年审电子证书怎么查

柳州电工证在哪里年审电子证书怎么查 电工证年审要是搞错了地方,可能耽误你找工作。柳州电工证在哪里年审?很多人跑错了地方,还浪费时间。现在电工证都是电子证书了,查询和年审都要走线上流程,别再傻乎乎地去线下乱问。这篇文章就告诉你柳州电工证年审的… · 2026/11/28 3:47:46

萧山电工证在哪办理 2026河南最新政策下如何高效通关
萧山电工证在哪办理 2026河南最新政策下如何高效通关

萧山电工证在哪办理 2026河南最新政策下如何高效通关 工地太忙根本没时间复习考试,这几乎是每个电工从业者的心声。特别是像河南这样的工程大省,项目多、节奏快,很多电工证考试和复审往往被拖延,等到真正需要时才发现证书已经过期,不仅影响工作,还… · 2026/11/28 3:47:46

柳州电工证在哪里年审千万别踩坑 电工证年审攻略和避坑指南
柳州电工证在哪里年审千万别踩坑 电工证年审攻略和避坑指南

柳州电工证在哪里年审千万别踩坑 电工证年审攻略和避坑指南 工地太忙根本没时间复习考试,很多人以为电工证考下来就万事大吉了,其实不然,年审和复审一样重要,搞不好就丢了饭碗,甚至面临罚款、停工、法律责任。尤其是现在建筑行业越来越规范,… · 2026/11/28 3:47:46

资溪电工证考前押题怎么准备才能一次过
资溪电工证考前押题怎么准备才能一次过

资溪电工证考前押题怎么准备才能一次过 怕考不过白交培训费,这是很多准备考资溪电工证的朋友最怕的事情。尤其是对那些已经投入了培训费、时间精力,却还担心自己跟不上进度的考生来说,考前押题就成了救命稻草。今天咱们就来聊聊,怎么通过 考前押题… · 2026/11/28 3:47:46

萧山电工证在哪办理怎么查网上查询
萧山电工证在哪办理怎么查网上查询

萧山电工证在哪办理怎么查网上查询 之前考的证在外省能不能转过来?萧山电工证在哪办理,网上查询一下就知道了。这可能是很多在萧山或者准备在萧山发展的电工最关心的问题。别急,今天咱就从头聊到尾,看看萧山电工证到底值不值得考,怎么考,还能不能转过来… · 2026/11/28 3:47:46

特种工电工证考试试题怎么准备?官方报名入口在这儿
特种工电工证考试试题怎么准备?官方报名入口在这儿

特种工电工证考试试题怎么准备?官方报名入口在这儿 证书过期了不知道怎么复审延期,这个问题让很多电工从业者头疼不已。尤其是在南阳卧龙区,从事公路工程的电工,如果特种作业操作证到期没有及时办理延期,轻则影响日常工作,重则面临停工整顿甚至行政处罚… · 2026/11/28 3:46:46

平价的电工证查询保姆级教程:别被中介坑,一步步教你搞定
平价的电工证查询保姆级教程:别被中介坑,一步步教你搞定

平价的电工证查询保姆级教程:别被中介坑,一步步教你搞定 你是不是也经常在网上看到“平价的电工证查询”这样的关键词,但又不知道去哪报名,怕被中介坑?特别是像你这样的平顶山学员,既想考个正规电工证,又怕花冤枉钱走弯路。别担心,这篇保姆级教程就是… · 2026/11/28 1:08:19

麻阳考电工证在哪里考内部消息你知道吗
麻阳考电工证在哪里考内部消息你知道吗

麻阳考电工证在哪里考内部消息你知道吗 不知道去哪报名怕被中介坑, 内部消息 告诉你,麻阳考电工证不一定要去外地,本地其实也有正规渠道,但很多人因为不了解流程和资质,反而被坑了钱还考不到证。今天我就从一个干了这么多年特种作业培训的“老江湖”角… · 2026/11/27 3:38:27

揭阳普宁电工证换证怎么操作?良心建议帮你理清流程
揭阳普宁电工证换证怎么操作?良心建议帮你理清流程

揭阳普宁电工证换证怎么操作?良心建议帮你理清流程 之前考的证在外省能不能转过来?这是很多已经在外地工作、现在想回揭阳普宁发展的电工朋友最关心的问题。如果你也是其中之一,那这篇文章就是为你们量身定制的,从换证流程到避坑建议,良心建议全给你讲透… · 2026/11/27 17:56:55

电工证在西安哪里办?外省证能转过来吗?上岗必备全流程详解
电工证在西安哪里办?外省证能转过来吗?上岗必备全流程详解

电工证在西安哪里办?外省证能转过来吗?上岗必备全流程详解 之前考的证在外省能不能转过来?这是很多从外地来西安工作的电工最关心的问题。特别是那些在郑州、洛阳、开封等地从事房建工程的电工,随着项目转移到西安,证件问题成了摆在眼前的“上岗必备”难… · 2026/11/28 0:00:19

广东考电工证别再踩坑了!良心建议帮你搞懂报考流程和职业前景
广东考电工证别再踩坑了!良心建议帮你搞懂报考流程和职业前景

广东考电工证别再踩坑了!良心建议帮你搞懂报考流程和职业前景 电工证不光是上岗的通行证,更是你进入工地、工厂、维修行业的“敲门砖”。很多小伙伴都遇到过这种情况:刚拿到证就过期了,换证流程搞不清楚,耽误了工作机会。别急,这篇文章就是给你一个… · 2026/11/28 0:00:19

工地太忙根本没时间复习考试?三方电工证合作机构值不值得考
工地太忙根本没时间复习考试?三方电工证合作机构值不值得考

工地太忙根本没时间复习考试?三方电工证合作机构值不值得考 你是不是也这样,整天在工地上跑来跑去,连吃饭的时间都紧张,更别提抽空复习考试了?尤其是像 三方电工证合作机构 这类证书,听起来门槛不低,但你可能还在纠结—— 值不值得考… · 2026/11/28 0:00:19

双极步进电机控制实战:DRV8818PWPR与PIC18F86K22驱动调试
双极步进电机控制实战:DRV8818PWPR与PIC18F86K22驱动调试

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views … · 2026/11/28 0:39:37

STM32F207ZG + DRV8818PWPR 步进电机驱动实战解析
STM32F207ZG + DRV8818PWPR 步进电机驱动实战解析

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views … · 2026/11/27 17:16:48

DRV8818PWPR+dsPIC30F4013工业级双极步进电机控制方案
DRV8818PWPR+dsPIC30F4013工业级双极步进电机控制方案

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views … · 2026/11/27 17:26:35

了解更多?预约专属演示

我们的顾问将为您一对一讲解产品与方案

企业微信二维码