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

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.

主站蜘蛛池模板: 马公市| 彭水| 双峰县| 顺昌县| 江陵县| 孟津县| 樟树市| 泰安市| 禹城市| 宁波市| 永州市| 兴山县| 新民市| 丰镇市| 藁城市| 双桥区| 江陵县| 开平市| 许昌县| 牙克石市| 安新县| 梓潼县| 桃源县| 朝阳市| 双柏县| 宜兴市| 五指山市| 敦化市| 长寿区| 黔西县| 隆尧县| 新野县| 义乌市| 东至县| 霞浦县| 樟树市| 建瓯市| 禹州市| 临沂市| 西乌珠穆沁旗| 荣昌县|