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

Starting from scratch

Let's start out by creating a new Angular project using the Angular CLI. We'll name it mastering-angular-components:

  1. Open a console window and navigate to a proper workspace for our project. Let's use the Angular CLI to create our initial project structure:
ng new mastering-angular-components --prefix=mac
  1. After the project has been successfully created, let's move into the project folder and start serving using the ng serve command:
cd mastering-angular-components
ng serve

After following the preceding steps, you should be able to open up your browser and point it to http://localhost:4200. You should be able to see the generated application app with a welcome message saying Welcome to mac!.

It's recommended that you leave the serving mode of the CLI running all the time while in development. Since the underlying webpack will use caching when recompiling the output bundles, it will speed up your development process quite a lot. I recommend that you always have a second command-line window open and start Angular CLI in serve mode there.

Let's examine what the Angular CLI tool has created for us so far. Along with a lot of files that we'll cover in later chapters, the Angular CLI tool has created the core files that are needed in order to assemble a simple Angular application. The following directory listing shows all the critical files, which you'll also find within your generated project folder:

mastering-angular-components
├── node_modules
├── package.json
└── src
├── app
│ ├── app.component.css
│ ├── app.component.html
│ ├── app.component.ts
│ └── app.module.ts
├── index.html
├── styles.css
└── main.ts

Let's take a quick look at these dependencies, development dependencies, and their purpose:

主站蜘蛛池模板: 沁源县| 揭阳市| 上饶县| 荃湾区| 廊坊市| 佛学| 忻州市| 铜鼓县| 乌兰察布市| 闽清县| 上杭县| 梨树县| 长子县| 鄯善县| 扎囊县| 宜都市| 许昌市| 平阴县| 灌云县| 南开区| 绿春县| 修武县| 梨树县| 唐河县| 邵武市| 聂拉木县| 阜阳市| 香港 | 松江区| 汨罗市| 北宁市| 南昌县| 德保县| 康定县| 桃园县| 二连浩特市| 玛多县| 东光县| 包头市| 法库县| 固安县|