Angular新建应用_angular-new-app

发布时间:2026/9/10 8:21:36

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/9/9 3:25:10

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

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

2026/9/10 10:12:13

CANN/ge矩阵形状内存计算

关于A、B、C矩阵的Shape及内存大小计算公式 【免费下载链接】ge GE(Graph Engine)是面向昇腾的图编译器和执行器,提供了计算图优化、多流并行、内存复用和模型下沉等技术手段,加速模型执行效率,减少模型内存占用。 GE …

2026/9/10 10:12:13

CANN/ge:创建模型数据集API

aclmdlCreateDataset 【免费下载链接】ge GE(Graph Engine)是面向昇腾的图编译器和执行器,提供了计算图优化、多流并行、内存复用和模型下沉等技术手段,加速模型执行效率,减少模型内存占用。 GE 提供对 PyTorch、Tenso…

2026/9/10 10:07:12

SpringBoot+Vue非遗文化传承网站开发实践

1. 非遗文化传承网站系统概述这个基于SpringBootVue的非遗文化传承网站系统,本质上是一个面向非物质文化遗产保护与传播的数字化解决方案。作为一名参与过多个文化类项目开发的老兵,我深知这类系统的核心价值在于如何平衡技术实现与文化呈现的关系。系统…

2026/9/9 13:11:35

超人会飞不算本事:系统稳定依赖清晰规则与边界设计

开头先不绕弯子。“#斯坦李吐槽dc 所以超人是无缘无故会飞的嘛哈哈哈哈哈哈哈锤哥真是技术人才啊!#雷神 #复联”这类调侃式短标题,第一波冲击力在于它把两个宇宙的角色塞进同一个吐槽箱里,但细想一下就能发现,它真正碰到的根本不是…

2026/9/8 7:15:15

超人VS蜘蛛侠:拆解超级IP的影响力与传播方法论

把“蜘蛛侠 vs 超人”放在 CSDN 上聊,可能很多人第一反应是走错片场了。但如果把这两个角色看成“两个持续运营了 80 多年的文化产品”,你会发现,这场比较本质上是两个不同 IP 策略的长期结果对比:超人赢在定义了整个超级英雄题材…

2026/9/9 16:31:09

基于CNN的调制信号识别:MATLAB实现时频图分类实战

简介:本资源是一套面向通信工程与信号处理方向学习者、研究者的深度学习实践方案,聚焦调制信号自动检测与识别这一典型无线通信任务,解决传统方法依赖人工特征、低信噪比下性能下降等痛点。压缩包共12个文件(10.73MB)&…

2026/9/10 0:00:55

目录对比去重实战:用哈希算法精准清理重复文件

我电脑里现在还有一块换了三次机的“数据墓地”硬盘,里面存着2016年以前所有旧笔记本的完整备份。平时不觉得有什么,直到前阵子想把它整理归档,发现同一个安装包、同一批照片、同一份论文草稿,在几个不同的备份目录里反复出现。更…

2026/9/10 0:00:55

Leaflet离线地图完整Demo合集:内网部署与坐标纠偏实战

简介:这是一份面向Web GIS开发者的LeafLet离线地图示例合集,帮助开发者快速掌握离线地图从搭建到交互的完整流程。压缩包共723个文件,大小14.06MB,以319个js脚本、175个html页面和29个css样式文件为主体,配合png/svg图…

2026/9/10 0:00:55

MATLAB读取Rinex 3.02观测文件:多系统GNSS数据解析实战

简介:基于MATLAB开发的Rinex3.02版观测文件(o文件)读取代码包,面向卫星定位导航方向的学习者与研究人员,用于解决新版观测文件的数据解析、历元提取与时间转换问题。压缩包共4个文件,包含两个m脚本、一个19…

2026/9/7 16:23:03

USB Type-C PCB布局分区设计:电源、高速信号与PD协议全攻略

做硬件这行,Type-C接口算是典型的“看着简单,做起来全坑”的东西。光引脚就24个,高低速信号、电源、控制线全部塞在一个小小的连接器里,如果PCB布局不做规划,打样回来基本就是“插上没反应”、“高速掉线”、“静电一打…

2026/9/7 22:46:00

系统编程学习原型如何补齐稳定性边界

系统编程学习原型如何补齐稳定性边界预算有限时&#xff0c;我先优化明显多余的复制&#xff0c;而不是猜测性地换容器。用借用传递只读数据通常就能减少分配&#xff1a; fn parse(line: &str) -> Result<Item, Error> { /* ... */ }用基准确认热点确实在分配&am…

2026/9/9 10:21:54

雨花区哪家财务公司代理记账比较好?

在雨花区&#xff0c;企业处理财税事务常常面临诸多挑战&#xff0c;选择一家靠谱的财务公司至关重要。湖南巨勤财务管理咨询有限公司就是本地正规实体财税服务机构&#xff0c;深耕本地工商财税行业多年&#xff0c;熟悉当地工商局、税务局最新政策与申报流程。主营公司注册、…

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

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

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