官术网_书友最值得收藏!

Generating scaffolding

Angular CLI allows us to generate components, services, directives, routes, pipes, and many more with ng generate. Here is how you would generate a component:

ng generate component path/name

For example, if we run the following command:

ng generate component shared/message

Four files will be generated and one updated. The produced output will be:

installing component
create src/app/shared/message/message.component.scss
create src/app/shared/message/message.component.html
create src/app/shared/message/message.component.spec.ts
create src/app/shared/message/message.component.ts
update src/app/app.module.ts

The new component is registered in app.module.ts automatically. The generation of other scaffoldings is identical. For example, to generate a service, run this command:

ng generate service path/name

There are plenty of useful options. You can set, for example, --spec=false to skip test file generation.

主站蜘蛛池模板: 曲沃县| 泾川县| 潞西市| 宁阳县| 巴林右旗| 鲁山县| 齐齐哈尔市| 天台县| 巴林左旗| 象州县| 海安县| 略阳县| 通许县| 徐汇区| 康马县| 新丰县| 双江| 德钦县| 明水县| 姚安县| 郴州市| 嵊州市| 独山县| 敦化市| 山阳县| 镇江市| 阿克苏市| 门头沟区| 铜陵市| 应城市| 岑巩县| 和顺县| 民县| 江川县| 化隆| 临漳县| 台安县| 武平县| 郓城县| 嵊州市| 徐汇区|