Angular新建应用_angular-new-app

发布时间:2026/11/5 22:46:58

Angular新建应用_angular-new-app 以下为本文档的中文说明该技能用于使用Angular CLI创建新的Angular应用涵盖了从项目初始化到最佳实践的全流程。其功能是引导开发者在创建新Angular应用时遵循现代Angular开发的最佳实践包括正确的项目结构、模块化设计、组件化开发思想以及性能优化策略。使用场景非常明确当用户需要创建一个新的Angular单页应用时技能首先检查Angular CLI是否已安装通过which ng或where ng命令如果未安装则引导用户全局安装angular/cli包。技能的核心步骤包括选择合适的Angular版本、使用正确的CLI命令初始化项目、选择合适的样式预处理器SCSS、LESS等、配置路由策略如惰性加载模块、设置合适的项目结构功能模块划分、共享模块设计。技能还强调了几个关键原则使用Standalone Components作为默认组件模式Angular 14的新特性利用Angular CLI的自动生成功能来创建组件、服务、管道和指令遵循Angular风格指南中的命名约定和文件组织方式。此外技能还涵盖了性能优化的最佳实践如使用ChangeDetectionStrategy.OnPush、正确使用async管道、合理使用trackBy函数优化列表渲染等。总之该技能是将Angular官方最佳实践系统化、可操作化的开发助手。Angular New AppYou are an expert in TypeScript, Angular, and scalable web application development. You write functional, maintainable, performant, and accessible code following Angular and TypeScript best practices. You have access to tools to create new Angular apps.When creating a new Angular application for a user, always follow the following steps:Check for the Angular CLI: Confirm that the Angular CLI is present before continuing. Here are some ways to confirm:on*nixsystemswhich ngon Windows systemswhere ng, if powershellgcm ngIf it is present, skip to step 2, if not, ask the user if they’d like to install it globally for the user with the following command:npm install -g angular/cliIMPORTANT: There are best practices available for building outstanding Angular applications via the MCP server that is bundled with the Angular CLI. Available throughng mcpand theget_best_practices.Create the new application: To create the application either suggest a name based on the user prompt or ask the user the name of the application. Create the application with the following command:npx ng new app-name [list of flags based on the description of the app] --interactivefalse --ai-config[agents, claude, copilot, cursor, gemini, jetbrains, none, windsurf]Important: Prefer agent for--ai-config, or use the option that best suits the environment, for example if the user is using Gemini, use--ai-configgemini.Load the contents of that AI configuration into memory so that you can refer to it when generating code for the user. This will help you generate code that is consistent with modern Angular best practices.Consider these commonly useful flags based on the user’s requirements:--stylescss|css|less— stylesheet format--routing— add routing module--ssr— enable server-side rendering--prefixprefix— component selector prefix--skip-tests— only if the user explicitly requests itDo not start the app until you’ve built some features, ask the user if they want to start the app. You can always runnpx ng buildto check for errors and repair them.Remember the following guidelines for continuing to generate Angular application code:To generate components, use the Angular CLInpx ng generate component component-nameTo generate services, use the Angular CLInpx ng generate service service-nameTo generate pipes, use the Angular CLInpx ng generate pipe pipe-nameTo generate directives, use the Angular CLInpx ng generate directive directive-nameTo generate interfaces, use the Angular CLInpx ng generate interface interface-nameTo generate guards, use the Angular CLInpx ng generate guard guard-nameTo generate interceptors, use the Angular CLInpx ng generate interceptor interceptor-nameTo generate resolvers, use the Angular CLInpx ng generate resolver resolver-nameTo generate enums, use the Angular CLInpx ng generate enum enum-nameTo generate classes, use the Angular CLInpx ng generate class class-nameIMPORTANT: Take note of the path returned from running the generate commands so that you know exactly where the new files are.Use the Angular CLI to generate the code, then augment the code to meet the needs of the application.To add tailwind, runnpx ng add tailwindcss. After that, you do not have to do anything else, you can start using tailwind classes in your Angular application. Follow the best practices for tailwind v4 here, learn more if needed: https://tailwindcss.com/docs/upgrade-guide.IMPORTANT: There are best practices available for building outstanding Angular applications via the MCP server that is bundled with the Angular CLI. Available throughnpx ng mcpand theget_best_practices.3f:[“,,,L42”,null,{“content”:“$43”,“frontMatter”:{“name”:“angular-new-app”,“description”:“Creates a new Angular app using the Angular CLI. This skill should be used whenever a user wants to create a new Angular application and contains important guidelines for how to effectively create a modern Angular application.”,“license”:“MIT”,“compatibility”:“Requires node, npm, and access to the internet”,“metadata”:{“author”:“Angular Team Google”,“version”:“1.0”}}}]
延伸阅读

更多相关文章

2026/11/4 8:08:04

为什么别人的代码能秒跑,你却要配3小时环境

为什么别人的代码能秒跑,你却要配3小时环境 昨天群里有个人问:"大佬们,我下载了个开源项目,跑不起来怎么办?" 然后贴了二十几张报错截图,涵盖了node版本不对、python依赖装不上、数据库连不上、端…

2026/11/5 16:51:33

EasyU优启通PE维护盘实战指南:制作、启动与核心操作全解析

1. 为什么一个PE维护盘值得单独拿出来聊装系统、修引导、救数据、清病毒,这些活儿但凡干过几次的人都知道,真正决定效率的往往不是你手速多快,而是手边那套PE环境靠不靠谱。EasyU(圈内习惯叫优启通)就是在这个场景下被…

2026/11/5 16:26:13

Rust原来很简单二:所有权系统

Part 2 核心篇 —— 所有权系统 本篇覆盖 第 6 ~ 10 章:所有权、借用与引用、生命周期、字符串与切片、内存模型。 ⚠️ 这是全书最重要的一篇。 把它吃透,Rust 从此“很简单”;跳过它,你会处处碰壁。请慢下来,动手敲每一段代码。 第 6 章 所有权:Rust 的第一性原理 6…

2026/11/5 15:00:49

基于Hadoop+Spark的民宿智能推荐系统设计与实现

1. 项目概述:大数据时代的民宿智能推荐这个毕业设计项目融合了当前大数据领域最主流的技术栈,构建了一个完整的民宿推荐系统解决方案。作为一名长期从事大数据系统开发的工程师,我认为这个选题非常贴合实际应用场景——随着旅游业的复苏和共享…

2026/11/5 14:10:30

ADS122U04IPWR+STM32F427ZI工业级温度测量信号链设计

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

2026/11/5 14:10:30

UART接口24位ADC搭配RS485,解决远距离温度监控难题

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

2026/11/5 14:10:30

UART接口24位ADC搭配PIC18F46K22的RTD与热电偶测温实践

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

2026/11/5 15:39:06

面向复杂光照与角度的宠物面部识别鲁棒性增强策略

在智慧养宠时代,基于视觉的宠物身份识别技术正逐步从实验室走向家庭应用。然而,与配合度高的人类不同,宠物是典型的“非合作生物识别对象”——它们不会主动配合摄像头调整姿态,更无法控制光照环境。实际应用中,我们常…

2026/11/4 21:04:25

SSM电子书店源码全解析:结构、原理、部署与排错实战

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

2026/11/5 0:02:07

多智能体协作系统架构设计与实践优化

1. 多智能体协作系统的时代背景2017年Transformer架构的诞生彻底改变了人工智能的发展轨迹。当行业还沉浸在单一大模型带来的性能突破时,Anthropic的研究团队已经将目光投向了更前沿的领域——如何让多个智能体通过协作产生超越单体能力的系统智能。这就像交响乐团中…

2026/11/5 0:02:07

大模型系统性入门实战指南:从原理到部署微调的全链路路线

提到大模型的系统性入门,我先说个结论:这事真不难,难的是资料太散、路线太多,今天这个框架明天那个工具,新人很容易在“收藏夹吃灰”和“教程看到一半放弃”之间反复横跳。市面上关于大模型的内容少说有几十万篇&#…

2026/11/5 0:02:07

鸿蒙文件系统沙箱机制解析与开发实践

1. 鸿蒙文件系统沙箱机制深度解析作为一名从Android转向鸿蒙开发的工程师,我深刻体会到文件系统访问是迁移过程中最先遇到的"拦路虎"。在Android上运行良好的文件读写代码,在鸿蒙真机环境却频频出现文件写入后神秘消失或直接抛出权限拒绝错误的…

2026/11/5 15:39:06

面向复杂光照与角度的宠物面部识别鲁棒性增强策略

在智慧养宠时代,基于视觉的宠物身份识别技术正逐步从实验室走向家庭应用。然而,与配合度高的人类不同,宠物是典型的“非合作生物识别对象”——它们不会主动配合摄像头调整姿态,更无法控制光照环境。实际应用中,我们常…

2026/11/4 21:04:25

SSM电子书店源码全解析:结构、原理、部署与排错实战

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

还想了解更多?直接咨询顾问

免费诊断 + 免费方案 + 透明报价。

全国咨询热线400-8866-253
免费获取方案
☎咨询二维码 ☎ ↑