angular - "ng add"在 Angular CLI 6.0.8 中做什么

标签 angular angular-cli

ng add <collection> 似乎没有任何文档Angular 6 的命令。这似乎是一项新功能,但我不知道它的作用。

它没有在官方 Wiki 页面上列出:

https://github.com/angular/angular-cli/wiki

命令有一个子 Wiki 页面:

https://github.com/angular/angular-cli/wiki/add

但是它说的和命令行帮助是一样的。

Add support for a library to your project.

他们指的是什么图书馆?是像https://material.angular.io/这样的图书馆吗?或者是别的什么?

最佳答案

blog 中有一篇很好的文章解释了这个新功能

Another new CLI command ng add makes adding new capabilities to your project easy. ng add will use your package manager to download new dependencies and invoke an installation script (implemented as a schematic) which can update your project with configuration changes, add additional dependencies (e.g. polyfills), or scaffold package-specific initialization code.

Because ng add is built on top of schematics and the npm registry, our hope is that libraries and the community will help us build a rich ecosystem of ng add supporting packages.

Take a look at Angular Material’s ng-add schematic for an example to help you get started building your own ng-add schematics.

例如,该命令可以自动更新您的 app.module.ts 等,使您能够直接使用该库,而无需进一步的麻烦

关于angular - "ng add"在 Angular CLI 6.0.8 中做什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51109959/

相关文章:

Angular 2获取当前路线

javascript - 识别和打印对象中的对象 - Angular

html - 正确的 FAB 位置 Material Angular

angular - 如何在 Angular 4 中使用 ng-bootstrap 将数据模态组件传递给父组件

angular-cli - 如何使用 Angular-Cli (v.1.0.0) 默认生成 Angular 2 项目

angular - 为 Angular 应用程序缓存 Assets 文件夹中的静态文件(图像、pdf、png 等)?

css - Angular CLI 没有 LESS/SASS 的源映射

Angular - 为什么我的弹珠测试不适用于包含用户权限的BehaviorSubject?

angular - 找不到本地工作区文件 ('angular.json')。但是相同的代码在另一台计算机上工作

javascript - 带有 angular-cli 的 ASP.NET WebApi