Angular应用ng serve命令行的学习笔记

273 阅读1分钟

在Angular项目下执行命令行ng serve --open:


The ng serve command builds the app, starts the development server, watches the source files, and rebuilds the app as you make changes to those files.
The --open flag opens a browser to http://localhost:4200/.

ng serve命令行执行的事情:

(1) build应用,开启development服务器,监听source文件的修改,一旦有文件被编辑,立即自动重新build应用
(2) --open选项的作用:开启浏览器打开该应用。

浏览器里显示的应用如下:

我们看到的实际是一个Application shell.这个shell被一个Angular Component控制。

Component是Angular里一个核心概念,负责显示数据到页面上,监听用户输入并响应。

ng serve命令行在Windows10系统上实际的执行明细

运行的是node_modules文件夹下@angular\cli\bin文件夹里的ng:

在这里插入图片描述

要获取更多Jerry的原创文章,请关注公众号"汪子熙":