一. 环境配置:

1.安装nodjs , npm 内部连接地址:http://www.mxlog.cn/1005.html;

外部链接地址:http://www.cnblogs.com/zhouyu2017/p/6485265.html

2.安装淘宝镜像镜像cnpm;

npm install -g cnpm --registry=https://registry.npm.taobao.org

(:这里如果你选这了淘宝的cnmp镜像,应该 最好在安装完全局Angular cli后设置一下,保证正常下载工具; ng set global packageManage = cnpm)

3.全局安装angular@cli

cnpm install -g @angular/cli

二. 创建、启动项目:

1.创建项目,名为my-app

ng new my-app

2.启动项目

ng serve 或者 ng start ;

(:默认端口:4200;访问地址:http://localhost:4200);

ng serve -p 3000
(:修改启动端口位:3000)

三. 为项目添加组件:

ng g component componentName

四. 引入第三方插件(如jQuery, bootstrap):

1.引入文件到node_model模块中

cnpm install bootstrap --save

(注: 安装制定版本插件:cnpm install bootstrap@版本号 --save 例如: cnpm install bootstrap@3.3.7 --save)

cnpm install jquery --save

2.配置angular-cli.json 如图:

http://files.jb51.net/file_images/article/201705/201752795444028.png?201742795456

(注: angular使用的是typescript语言,以便让typescript认识bootstrap和jQuery一些字符(比如jQuery的$等 需要配置)
cnpm install @types/bootstrap --save --dev
cnpm install @types/jquery --save --dev