写在前面
是Angular 不是angular.js!!!
本文只是列举一些ng开发中的注意事项,有一些是自己遇到的坑,总结一下分享…
构建项目
- 安装
npm install -g @angular/cli
- 创建项目
ng new name
- 安装这一块官网上面写的很详细了Angular安装起步
项目运行起来
ng serve
使用http://localhost:4200
访问ng serve --port 端口号
自定义端口号访问ng serve --host 本机IP
使用本机IP访问,以供局域网中设备访问
配置.angular-cli.json文件,引用其它js框架,css框架,或者使用less/sass语法
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"project": {
"name": "demo1"
},
"apps": [
{
"root": "src",
"outDir": "dist",
"assets": [
"assets",
"favicon.ico"
],
"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.app.json",
"testTsconfig": "tsconfig.spec.json",
"prefix": "app",
//样式放这里面,路径引用
"styles": [