Angular使用筆記1_Angular的歷史_Angular1跟Angular2比較

 








Angular本身是由Google提出的一套base on MVC架構的
(可跟常見的後端程式語言PHP、.NET、NodeJS搭配開發)
Web Application的開源JS Framework
主要特色在於可以對HTML透過指令方式做彈性延伸達成動態內容建構。
除了網頁應用也可以建構手機應用(跟Ionic 、RN搭配)



主要會在介紹到
Angular的歷史與版本演進
Angular1跟Angular2比較
Angular 開發工具介紹
Angular CLI
Angular的使用場景
Angular的語法特點


Angular的歷史與版本演進
主要是在2009年由Misko Hevery 跟Adam Abrons兩個開發者設計出來的
Misko Hevery於2009年開始在Google工作
並且
於2012年由Google名義推出
Angular version 1.0 也就是AngularJS
  •  A JavaScript MVW Framework 
  •  Extends HTML by adding attributes, tags, and expressions
  •  Events Handling
  •  Powerful Data Binding
  •  Built-In Template Engine and Routing
  •  Form Validations and Animations
  •  Dependencies Injection etc.


於2016年9月則又釋出了Angular version 2.0
  •  Modern, faster and highly scalable framework
  •  One framework for web, mobile and desktop apps
  •  Not an update to Angular1.x, but a complete rewrite
  •  Written in Typescript
  •  Simple and Expressive
  •  Web components based architecture
  •  Hierarchical Dependency Injection

Angular 3.0 was not released since angular router package version was 3.0 in Angular 2. 
So development team skipped Angular version 3 and directly named it version 4 to maintain the same version number for all the Angular packages.


於2017年3月釋出Angular 4.x
  •  Smaller and Faster
  •  Reduce the size of generated bundled code up to 60%
  •  Animation moved out to a separated package @angular/animations
  •  Supports for if/else statement
  •  Supports for email validator


於2017年11月則又更新釋出Angular 5.x
  • Make AOT the default
  •  Easier to build progressive web apps
  •  Type checking in templates
  •  Internationalized Number, Date, and Currency Pipes
  •  An update to Httpclient
  •  Better error messages
  •  Zone speed improvements

於2018年5月釋出Angular 6.x
  •  ng add and ng update
  •  Bazel Compiler
  •  Angular Elements
  •  RxJS 6.0 Supports
  •  Better URL Serialization

於2018年10月釋出Angular 7.x
  • CLI Prompts
  • Improve Application Performance
  • Angular compilation options
  • Dependency Updates
    • TypeScript 3.1
    • RxJS 6.3
    • Node 10
於2019年5月釋出Angular 8.x
  • Easier to read and debug the generated code at runtime
  • Web Workers Support
  • Lazy Loading Improvements
  • Improvement to ngUpgrade
  • Faster re-build
........

Angular1跟Angular2比較

一般在社群或者業界對於AngularJS 跟 Angular關係不會畫上等號
兩者是不同的產品
AngularJS主要指Angular 1.0
而若只講Angular則代表version  2之後的 (4,5,6,7,8,9,10...)
兩者是沒有上下相容的,Angular 2是把整個第一代重新砍掉重造的新版本框架。
2.0之後的版本基本上都會上下相容,基本上升級不是問題,頂多
只是基於上一版再多擴充一些功能特性或者跟NodeJs的相容性擴充。
Angular 跟 AngularJS是兩個不同的東西

Angular(Angular2.x) is a development platform for building mobile and desktop web applications using Typescript/JavaScript and other languages.

AngularJS(Angular1.x) lets you write client-side web applications as if you had a smarter browser. 
It lets you use good old HTML (or HAML, Jade/Pug and friends!) as your template language and lets you extend HTML’s syntax to express your application’s components clearly and succinctly. It automatically synchronizes data from your UI (view) with your JavaScript objects (model) through 2-way data binding. To help you structure your application better and make it easy to test, AngularJS teaches the browser how to do dependency injection and inversion of control.

It also helps with server-side communication, taming async callbacks with promises and deferred objects, and it makes client-side navigation and deep linking with hashbang urls or HTML5 pushState a piece of cake. Best of all? It makes development fun!






Angular(Angular2.x) 跟 AngularJS(Angular1.x) 主要差異
Angular2.x 本身是based on components 再進行開設計而Angular1.x則是based on controller 跟scope
此外到Angular2.x後才有支援Typescript跟提供CLI ,並才具有Mobile First的機制。
更可運行在Server Side跟Client Side之間

AngularJS(Angular1.x) 

Based on MVC framework




Angular(Angular2+)架構圖

Based on the component tree, the interface that the user sees is composed of several activated components on the component tree, and the user can route from one component to another through operations. Components can introduce some services through DI (dependency injection), and use these services to process user operations or communicate with servers.





Angular的使用場景:
適合用於在建立CRUD的頁面(跟資料互動較為頻繁的)


Angular語法特點:
1.用雙大括號{{}}來做動態資料綁定
2.可將HTML元素程式碼藉由分合方式組成可複用的組件
3.支援Form之間的驗證
4.可用邏輯程式碼和DOM相互生成關聯





可以直接透過
npm install -g @angular/cli
對環境做全域下載安裝











留言

這個網誌中的熱門文章

何謂淨重(Net Weight)、皮重(Tare Weight)與毛重(Gross Weight)

Architecture(架構) 和 Framework(框架) 有何不同?_軟體設計前的事前規劃的藍圖概念

經得起原始碼資安弱點掃描的程式設計習慣培養(五)_Missing HSTS Header