ng-book 2 r60 (Angular 4) 簡介

Based on ng-book 2 r60 version, personal notes
基於 Angular 權威教程 r60版本 , 個人筆記

Angular CLI

不是必須,只是一個快速構建工具
not a requirement, simply a wrapper around Webpack.
install
npm install -g @angular/cli
usage
ng -help

start a new project

ng new XX
cd xx
ng service

默認端口

http://localhost:4200/
configure host
ng serve --host 0.0.0.0 --port 4201

新建組件

ng generate or ng g

Scaffold Usage
Component ng g component my-new-component
Directive ng g directive my-new-directive
Pipe ng g pipe my-new-pipe
Service ng g service my-new-service
Class ng g class my-new-class
Guard ng g guard my-new-guard
Interface ng g interface my-new-interface
Enum ng g enum my-new-enum
Module ng g module my-module

angular-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:

  1. ng g module new-module to create a new module
  2. call ng g component new-module/new-component

This 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@latest

Local 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

Angular版本

最早是叫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。兩個版本是兩個不同的項目。

Overall

本書可以分爲幾個部分:
基礎部分,創建第一個app, 使用內置組件並且學會創建組件。
中間部分,使用表格,APIs, 路由, 和依賴注入(Dependency Injection)
進階部分,數據結構,管理client和server的state,兩種方法:RxJS Observables 和Redux。
最終部分,學習寫出複雜的組件,寫出tests,如何從Anjular 1.x 升級到Anjular 4.0+,學習使用NativeScript寫出原生移動apps
本書目的:學習如何打造一個實戰Anjular項目,節省了在不同博客,教程之間查閱時間。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章