angularcli 第一篇(新建、组件、模块)


 

1、新建并启动项目:

1、安装:   npminstall -g @angular/cli
2、新建:   ng new mytest
3、进入项目:cd mytest
4、启动:   ng serve
5、打开项目: localhost:4200
注:拿到项目之后首先要:cnpm install然后才运行:ng serve (安装依赖:项目要跑起来首先要依赖一些包,cnpm install后会自动找到package.json匹配相应的包,进行下载,下载完装在node_modules里)

 

2、新建组件:

ng g component header

注: 只需要记得在 app.component.html 中加入 <app-header></app-header> 就可以看到header.component.html中编辑的内容。访问 http://localhost:4200/ 将会看到。

3、组件和模块介绍:

(1)根模块

(2)根组件

(3)子组件

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM