Angular应用ng serve命令行

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

Angular应用ng serve命令行
Angular应用ng serve命令行

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选项的作用:开启浏览器打开该应用。

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

Angular应用ng serve命令行

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

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

要获取更多Jerry的原创文章,请关注公众号"汪子熙":
Angular应用ng serve命令行