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

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.

主站蜘蛛池模板: 临江市| 蒲江县| 庆阳市| 六盘水市| 仪陇县| 柳州市| 公主岭市| 武冈市| 盐山县| 绥江县| 安陆市| 兴山县| 德格县| 绥德县| 收藏| 盱眙县| 永丰县| 扬州市| 广昌县| 郎溪县| 永定县| 阜城县| 门头沟区| 鹿泉市| 于田县| 南投县| 新干县| 红桥区| 仲巴县| 宜川县| 长春市| 延安市| 长乐市| 滦南县| 昂仁县| 高州市| 黄浦区| 合阳县| 临湘市| 岳普湖县| 噶尔县|