发布时间:2026/7/24 21:49: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/7/24 21:44:36

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

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

2026/7/24 23:25:05

TI AM570x DDR3 PCB设计实战:从堆叠到等长的信号完整性指南

1. 项目概述与核心挑战在嵌入式系统,尤其是像TI AM570x系列这样集成了Cortex-A15核心的高性能应用处理器设计中,DDR3内存子系统往往是决定整个系统稳定性和性能上限的关键。我经手过不少基于AM5708的工业网关和视觉处理项目,几乎每一次&#…

2026/7/24 23:25:05

一张图看懂TOGAF元模型主要实体之间的关系

本文对TOGAF 元模型的主要实体元素之间的关系进行解读,并对元模型中提及的重要概念进行名词解释或者举例说明。为保证语言通俗易懂,用一家加工螺丝钉的生产企业“螺丝霸王”为例举例说明,以便降低理解难度。(图片来源:…

2026/7/24 23:25:05

中兴光猫终极解锁指南:3步免费开启工厂模式与Telnet权限

中兴光猫终极解锁指南:3步免费开启工厂模式与Telnet权限 【免费下载链接】zteOnu A tool that can open ZTE onu device factory mode 项目地址: https://gitcode.com/gh_mirrors/zt/zteOnu 你是否曾经因为无法深度配置中兴光猫而感到困扰?想优化…

2026/7/23 12:54:51

Unity与Python本地通信:基于Flask的跨语言数据交换实战

1. 项目概述:为什么我们需要一个本地通信服务器?在游戏开发、数字孪生、仿真训练等众多领域,Unity作为强大的实时3D内容创作平台,其核心逻辑通常由C#驱动。然而,当我们需要进行复杂的数据分析、机器学习推理、科学计算…

2026/7/24 0:03:10

不同品牌斜齿行星减速机如何替换?以PX与PAG系列为例

不同品牌斜齿行星减速机如何替换?以 PX 与 PAG 系列为例 一、系列对应不等于型号直接互换 PX 与 PAG 都属于斜齿、方法兰、输出轴式精密行星减速机,结构形式和应用方向具有对应关系。 原设备使用PX系列时,可以优先从PAG系列中寻找替换型号。但…

2026/7/24 0:03:10

jdk8 把list 扁平化成String 多个以逗号分隔

在 JDK 8 中&#xff0c;将 List 扁平化为以逗号分隔的 String&#xff0c;有几种非常简洁且高效的方法。&#x1f680; 推荐方案&#xff1a;使用 Collectors.joining()这是最标准的 Java 8 写法&#xff0c;适用于 List<String>。javaimport java.util.stream.Collecto…

2026/7/24 0:03:10

java 两个 long id 怎么合并成一个long id 并且不重复

“把两个 Long ID 合并成一个唯一的 Long ID&#xff0c;且保证不重复”这个需求&#xff0c;在 Java 里直接做数学上的“完美合并”是不可能的。因为两个 Long&#xff08;各 64 位&#xff09;要合并成一个 Long&#xff08;64 位&#xff09;&#xff0c;在信息论上是有损压…

2026/7/23 23:42:43

3个高效策略:快速掌握Axure中文界面配置

3个高效策略&#xff1a;快速掌握Axure中文界面配置 【免费下载链接】axure-cn Chinese language file for Axure RP. Axure RP 简体中文语言包。支持 Axure 11、10、9。不定期更新。 项目地址: https://gitcode.com/gh_mirrors/ax/axure-cn 还在为Axure RP的英文界面感…