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

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.

主站蜘蛛池模板: 班戈县| 廊坊市| 阿荣旗| 虹口区| 台南市| 皮山县| 通许县| 高邑县| 旺苍县| 万载县| 永昌县| 安义县| 高唐县| 丰宁| 辽源市| 北流市| 南开区| 突泉县| 响水县| 屏南县| 正阳县| 治县。| 遵义市| 乌拉特中旗| 张家界市| 涪陵区| 浪卡子县| 龙口市| 上高县| 左云县| SHOW| 沧州市| 手游| 沂水县| 萝北县| 通化县| 措勤县| 宾阳县| 吴江市| 金昌市| 木兰县|