#####################环境搭建
安装nodejs
获取npm默认的下载仓库下载地址
npm config get registry
修改Npm 默认的下载仓库下载地址 为国内地址
npm config set registry 新仓库地址,如 https://registry.npm.taobao.org/
安装并下载脚手架:
npm i -g @angular/cli
小知识:使用第三方NPM下载仓库
查看当前NPM默认的下载仓库地址:
npm config get registry
修改NPM默认的下载仓库地址为国内镜像网站:
npm config set registry 新仓库地址
例如,可以使用淘宝提供的NPM镜像:
npm config set registry https://registry.npm.taobao.org
#####################创建项目
运行脚手架工具创建空白项目
管理员权限:
ng new 项目
cd 项目
npm start
运行项目
#####################项目介绍
(1)angular.json
main: ts主入口
index: 首页面,指定整个项目唯一完整的dom树
>自动引入了<app-root></app-root>,它就是DOM树
(2)main.js > bootStrapModule(AppModule)
引导启动目前惟一的模块
platformBrowserDynamic().bootstrapModule(AppModule)
.catch(err => console.error(err));
(3)app.module.ts
bootstrap指的是引导启动,这里引导启动了AppComponent
> bootstrap [AppComponent] 组件
(4)app.components.ts
定义了组建的三部分,模板,样式,行为script
# 选择器,指定这个组件想被使用,需要引入的选择器
>selector: 'app-root'
#模板
>'./app.component.html'
#样式
styleUrls: ['./app.component.css']
#行为
export class AppComponent { title = 'myngapp01'; }
(5)./app.component.html >HTML片段...
#####################angular核心概念----模块
1.模块
angular 中模块就是一个抽象容器,用于给组件分组
angular 初始化时就只有一个模块:AppModule