Based on ng-book 2 r60 version, personal notes 基于 Angular 权威教程 r60版本 , 个人笔记
Angular CLI start a new project默认端口新建组件更新 Angular版本Overall不是必须,只是一个快速构建工具 not a requirement, simply a wrapper around Webpack. install npm install -g @angular/cli usage ng -help
http://localhost:4200/ configure host ng serve --host 0.0.0.0 --port 4201
ng generate or ng g
ScaffoldUsageComponentng g component my-new-componentDirectiveng g directive my-new-directivePipeng g pipe my-new-pipeServiceng g service my-new-serviceClassng g class my-new-classGuardng g guard my-new-guardInterfaceng g interface my-new-interfaceEnumng g enum my-new-enumModuleng g module my-moduleangular-cli will add reference to components, directives and pipes automatically in the app.module.ts. If you need to add this references to another custom module, follow this steps:
ng g module new-module to create a new modulecall ng g component new-module/new-componentThis should add the new component, directive or pipe reference to the new-module you’ve created.
同时需要global and local Global package:
npm uninstall -g @angular/cli npm cache clean npm install -g @angular/cli@latestLocal project package:
rm -rf node_modules dist # use rmdir /S/Q node_modules dist in Windows Command Prompt; use rm -r -fo node_modules,dist in Windows PowerShell npm install --save-dev @angular/cli@latest npm install最早是叫AngularJS, 官方声明中,AngularJS指的是Angjular 1.x 版本。 后面的版本 Angular用了TypeScript替代JavaScript, 后缀JS去掉了,也被称为 Angular 2。 在2017年,Anjular团队用语义版本名称,也就是不再叫做Anjular X, 而只是Anjular。 没有数字。目前(2017)最新版本俗称Angjular 4。 Anjular 的JS版本也就是1.x版本,被指定为AnjularJS。后续版本目前(2017)就叫做Anjular。两个版本是两个不同的项目。
本书可以分为几个部分: 基础部分,创建第一个app, 使用内置组件并且学会创建组件。 中间部分,使用表格,APIs, 路由, 和依赖注入(Dependency Injection) 进阶部分,数据结构,管理client和server的state,两种方法:RxJS Observables 和Redux。 最终部分,学习写出复杂的组件,写出tests,如何从Anjular 1.x 升级到Anjular 4.0+,学习使用NativeScript写出原生移动apps 本书目的:学习如何打造一个实战Anjular项目,节省了在不同博客,教程之间查阅时间。