Angular Schematics 学习笔记
網址:https://angular.io/guide/schematics
A schematic is a template-based code generator that supports complex logic.
一個 Schematic 是一個基于模板的代碼生成器,能支持復雜邏輯。
It is a set of instructions for transforming a software project by generating or modifying code.
Schematics 是一套指令的集合,能夠通過生成或者更改代碼的方式,對一個軟件項目進行處理。
Schematics are packaged into collections and installed with npm.
Schematics 以 collections 的形式打包,通過 npm 安裝。
Collection: In Angular, a set of related schematics collected in an npm package.
Collection 是 Angular Schematics 特有的概念,一套 Schematics 打包成 npm package.
The schematic collection can be a powerful tool for creating, modifying, and maintaining any software project, but is particularly useful for customizing Angular projects to suit the particular needs of your own organization.
Schematics 是一種功能強大的工具,能創建,更改和維護軟件項目,但是在定制化 Angular 項目,以滿足組織特殊需求的這個領域里顯得格外有用。
You might use schematics, for example, to generate commonly-used UI patterns or specific components, using predefined templates or layouts.
比如我們可以使用 Schematics,根據預定義的模板或者布局信息,生成能夠普遍使用的 UI patterns,或者特別的 Components.
You can use schematics to enforce architectural rules and conventions, making your projects consistent and inter-operative.
可以使用 Schematics 來強化架構規則和規范,讓項目標準更加一致。
Schematics for the Angular CLI
Schematics 是 Angular 生態圈的一部分。
The Angular CLI uses schematics to apply transforms to a web-app project.
Angular CLI 使用 Schematics 來對 web app 項目施加更改。
You can modify these schematics, and define new ones to do things like update your code to fix breaking changes in a dependency, for example, or to add a new configuration option or framework to an existing project.
Schematics that are included in the @schematics/angular collection are run by default by the commands ng generate and ng add.
@schematics/angular 下面的 Schematics 默認被 ng generate 和 ng add 使用。
The package contains named schematics that configure the options that are available to the CLI for ng generate sub-commands, such as ng generate component and ng generate service.
這個包內包含了命名的 Schematics,能夠為 ng generate 等命令行提供配置 options.
在 schematics\angular\collection.json 文件里能看到 ng generate 命令所能生成的各種 Angular 元素:
看個例子:
更多Jerry的原創文章,盡在:“汪子熙”:
 
總結
以上是生活随笔為你收集整理的Angular Schematics 学习笔记的全部內容,希望文章能夠幫你解決所遇到的問題。
 
                            
                        - 上一篇: prometheus监控主机
- 下一篇: SAP Spartacus angula
