Angular CLI 命令可帮助我们非常快速地创建和启动项目。
npm install -g @angular/cli
要创建一个新项目,我们可以在命令行中运行以下命令,然后将创建该项目。
ng new PROJECT-NAME cd PROJECT-NAME ng serve
ng serve //将编译,您可以在浏览器中看到项目的输出-
http://localhost:4200/
创建新项目时,默认端口为4200。您可以使用以下命令更改端口-
ng serve --host 0.0.0.0 --port 4201
如果您想更新应用程序及其依赖关系,可以使用以下命令-
链接:https://www.learnfk.comhttps://www.learnfk.com/angular7/angular7-cli-prompts.html
来源:LearnFk无涯教程网
ng update @angular/cli @angular/core
它将核心框架更新到最新版本,即Angular 7和angular-cli。您可以将上述命令与以下选项一起使用-
下表列出了使用Angular 7项目时所需的一些重要命令-
序列号 | 命令和说明 |
---|---|
1 |
Component ng g component new-component |
2 |
Directive ng g directive new-directive |
3 |
Pipe ng g pipe new-pipe |
4 |
Service ng g service new-service |
5 |
Module ng g module my-module |
6 |
Test ng test |
7 |
Build ng build --configuration=production //用于生产环境 ng build --configuration=staging //用于说明环境 |
每当创建新模块,组件或服务时,它们的引用都会在父模块 app.module.ts 中更新。
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)