SlideShare a Scribd company logo
1 of 36
Angular 7
全新功能探索
多奇數位創意有限公司
技術總監 黃保翕 ( Will 保哥 )
http://blog.miniasp.com/
本日大綱
• Angular CLI v7
• Angular Material / CDK
• Angular Elements
• The Ivy Render Engine
• ng update
• Breaking Changes
Angular CLI v7
改善前端開發環境的終極武器
全新的 ng new / ng add 互動式介面
ng new demo1 --routing --style css
ng add @angular/material
ng generate component
• /angular/angular-cli/.../schematics/angular/component/schema.json#L21-L29
全新的 Angular CLI 官方文件
• https://angular.io/cli
• CLI Command Reference
• 使用說明已整合進 angular.io 官方網站
更小的 bundle size 推出
• Angular v6 以前,預設會從 srcpolyfills.ts 載入 reflect-metadata 套件
import 'core-js/es7/reflect';
• 但是預設 reflect-metadata 套件只會在 JIT 模式使用到
• 大部分 Angular 網站都是以 AOT 模式編譯執行,所以不需要載入這個套件!
• 從 Angular CLI v7 開始,會 全自動判斷 何時該載入這個 Polyfills!
Angular CLI 6: 載入 core-js/es7/reflect 模組
Angular CLI 7: 移除 core-js/es7/reflect 模組
大約差2/3 個 jQuery 大小 (20.7 KB)
正式推出 Bundle Budgets 功能
angular.json
ng build --prod
ng build --prod
示範錯誤的 rxjs 匯入方式
• 為了 RxJS 舊版的相容性,你在升級時可能會安裝 rxjs-compat
npm install rxjs-compat
• 早期不太好的匯入方式
import 'rxjs/Rx';
• 解決方案
• 設定 tslint.json 的 "import-blacklist" 匯入黑名單
• ng lint
Angular Material 與 CDK
全新功能:虛擬捲動 與 拖曳功能
虛擬捲動 (Virtual Scrolling)
• 匯入 ScrollingModule 模組
• https://material.angular.io/cdk/scrolling/overview
• PrimeNG 也正是內建 VirtualScroller ( 內建延遲載入、排序、篩選 )
https://twitter.com/cagataycivici/status/1063031348745650176
拖曳功能 (Drag and Drop)
• 匯入 DragDropModule 模組
• https://material.angular.io/cdk/drag-drop/overview
下拉選單 ( select / mat-form-field )
• 允許在 <mat-form-field> 標籤中使用 HTML 原生的 <select> 標籤
• https://material.angular.io/components/select/overview
Angular Elements
實現 "微前端" 的利器
Angular Elements 是什麼?
• https://angular.io/guide/elements ( 中文版 )
• 能將 Angular 元件封裝成 自訂元素 (Custom elements)
• 自訂元素 可以執行在 Chrome, Opera, 與 Safari 瀏覽器 (Edge?) (相容性)
• 推薦影片:Elements in v6 and Beyond - Rob Wormald
• Upgrading With Web Components: From AngularJS To Angular
Angular Elements 運作原理
1. 將自訂元素註冊至瀏覽器
2. 將自訂元素加入 DOM
3. 初始化自訂元素
4. 事件繫結 & 變更偵測
Angular Elements 起手式
• 文章:A Practical Guide to Angular Elements
• 範例:https://stackblitz.com/edit/angular-elements-official-example
• 設定步驟 ( ng new demo1 --routing false --style css )
1. 安裝 @angular/elements 套件
• ng add @angular/elements
2. 修改 tsconfig.json
• "target": "es2015",
3. 撰寫 Angular 元件
• ng g c made-with-love -v ShadowDom
4. 修改 src/angular.module.ts
• 刪除 AppComponent 元件 / 刪除 bootstrap 屬性 / 新增 ngDoBootstrap() 方法
• 新增 entryComponents 屬性並加入 MadeWithLoveComponent 元件
• import { createCustomElement } from '@angular/elements';
• 建立 constructor() 建構式並透過 createCustomElement() 建立自訂元素
可使用 <slot> 標籤 (content projection)
• 可以在自訂元素中使用自訂內容 (content)
• 可在自訂元素中使用 Web Components 標準的 <slot> 標籤
• Angular 6 範例 (Stackblitz) / Angular 7 範例 (Stackblitz)
<made-with-love name="Will" url="https://blog.miniasp.com">
<span slot="my-header">Header<hr></span>
<h1>OK</h1>
<span slot="my-footer"><hr>Footer</span>
</made-with-love>
<header>
<slot name="my-header"></slot>
<slot name="my-footer"></slot>
</header>
The Ivy Render Engine
劃時代的 Angular 渲染引擎
搶先體驗 Ivy 渲染引擎
• 免安裝立即體驗
npx @angular/cli@next new demo7-ivy --experimental-ivy --style css --routing
• 以 production 環境進行建置
ng serve --prod
ng build --prod
• 目前僅能在 macOS 環境下成功建置!
ng build --prod
最新 Ivy 發展進度:93.96%
• Ivy status
• AngularEvolution
• Is Angular Ivy Ready
• Design Doc (Ivy)
ng update
更新與升級 Angular 應用程式
更新與升級 Angular 應用程式
• https://update.angular.io/
• 更新過時的 rxjs 寫法
npm install -g rxjs-tslint
rxjs-5-to-6-migrate -p src/tsconfig.app.json
npm uninstall rxjs-compat
• 更新到 Angular v7
ng update @angular/cli @angular/core
ng update @angular/material
取得 Angular 版本資訊
• 查詢目前專案的 Angular CLI 版本
• ng version ( 早期的 ng -v 現在已經棄用 )
• 查詢 @angular/cli 套件的最新版本
• npm info @angular/cli dist-tags
Breaking Changes
關於升級時可能面臨的破壞性更新
關於破壞性更新的幾點提醒
• Angular v6:表單元素 <ngForm> 已棄用,請改用 <ng-form> 或繼續用 <form> 即可
• 預計 Angular v9 (2019-11) 會移除 <ngForm> 這種用法!
• Angular v6:雙向繫結的 [(ngModel)] 不要跟 Reactive Forms 的寫法一起使用
• <input [formControl]="control" [(ngModel)]="value">
• 預計 Angular v7 會移除這種使用方式,升級前請先行調整寫法!
• Angular v4:不要再用 <template> 標籤,改用 <ng-template> 為主!
Q & A
相關連結
• Version 7 of Angular — CLI Prompts, Virtual Scroll, Drag and Drop and more
• Angular CLI Command Reference
• How Did Angular CLI Budgets Save My Day And How They Can Save Yours
• Angular Elements Overview
• Is Angular Ivy Ready
• Angular Update Guide
THANK YOU
Angular 7 全新功能探索 (Angular Taiwan 2018)

More Related Content

What's hot

ModernWeb 2017 angular component
ModernWeb 2017 angular componentModernWeb 2017 angular component
ModernWeb 2017 angular componentChieh Kai Yang
 
AngularJS training in Luster
AngularJS training in LusterAngularJS training in Luster
AngularJS training in LusterJason Chung
 
保哥線上講堂:利用 StyleCop 撰寫一致的 C# 程式碼風格
保哥線上講堂:利用 StyleCop 撰寫一致的 C# 程式碼風格保哥線上講堂:利用 StyleCop 撰寫一致的 C# 程式碼風格
保哥線上講堂:利用 StyleCop 撰寫一致的 C# 程式碼風格Will Huang
 
快快樂樂學 Angular 2 開發框架
快快樂樂學 Angular 2 開發框架快快樂樂學 Angular 2 開發框架
快快樂樂學 Angular 2 開發框架Will Huang
 
進擊的前端工程師:今天就用 JSON Server 自己打造 API 吧!
進擊的前端工程師:今天就用 JSON Server 自己打造 API 吧!進擊的前端工程師:今天就用 JSON Server 自己打造 API 吧!
進擊的前端工程師:今天就用 JSON Server 自己打造 API 吧!Will Huang
 
使用 ASP.NET 5 實戰開發雲端應用程式
使用 ASP.NET 5 實戰開發雲端應用程式使用 ASP.NET 5 實戰開發雲端應用程式
使用 ASP.NET 5 實戰開發雲端應用程式Will Huang
 
DEV305 - ASP.NET 5 開發攻略
DEV305 - ASP.NET 5 開發攻略DEV305 - ASP.NET 5 開發攻略
DEV305 - ASP.NET 5 開發攻略Will Huang
 
ASP.NET 5 的創新與變革
ASP.NET 5 的創新與變革ASP.NET 5 的創新與變革
ASP.NET 5 的創新與變革Will Huang
 
使用 TypeScript 駕馭 Web 世界的脫韁野馬:以 Angular 2 開發框架為例
使用 TypeScript 駕馭 Web 世界的脫韁野馬:以 Angular 2 開發框架為例使用 TypeScript 駕馭 Web 世界的脫韁野馬:以 Angular 2 開發框架為例
使用 TypeScript 駕馭 Web 世界的脫韁野馬:以 Angular 2 開發框架為例Will Huang
 
Azure Web App on Linux @ Global Azure Bootcamp 2017 Taiwan
Azure Web App on Linux @ Global Azure Bootcamp 2017 TaiwanAzure Web App on Linux @ Global Azure Bootcamp 2017 Taiwan
Azure Web App on Linux @ Global Azure Bootcamp 2017 TaiwanWill Huang
 
Frontend Devops at Cloudinsight
Frontend Devops at CloudinsightFrontend Devops at Cloudinsight
Frontend Devops at CloudinsightYan Wang
 
React.js what do you really mean?
React.js what do you really mean?React.js what do you really mean?
React.js what do you really mean?昱安 周
 
改善 Angular 開發流程:你所不知道的 Schematics 程式碼產生器
改善 Angular 開發流程:你所不知道的 Schematics 程式碼產生器改善 Angular 開發流程:你所不知道的 Schematics 程式碼產生器
改善 Angular 開發流程:你所不知道的 Schematics 程式碼產生器Chieh Kai Yang
 
Angular js twmvc#17
Angular js twmvc#17Angular js twmvc#17
Angular js twmvc#17twMVC
 
ASP.NET MVC 6 新功能探索
ASP.NET MVC 6 新功能探索ASP.NET MVC 6 新功能探索
ASP.NET MVC 6 新功能探索Will Huang
 
AKS 與開發人員體驗 (Kubernetes 大講堂)
AKS 與開發人員體驗 (Kubernetes 大講堂)AKS 與開發人員體驗 (Kubernetes 大講堂)
AKS 與開發人員體驗 (Kubernetes 大講堂)Will Huang
 
使用 Angular 2 與 Firebase 實現 Serverless 網站架構 (JSDC.tw 2016)
使用 Angular 2 與 Firebase 實現 Serverless 網站架構 (JSDC.tw 2016)使用 Angular 2 與 Firebase 實現 Serverless 網站架構 (JSDC.tw 2016)
使用 Angular 2 與 Firebase 實現 Serverless 網站架構 (JSDC.tw 2016)Will Huang
 
Angular.js & ASP.NET in Study4
Angular.js & ASP.NET in Study4Angular.js & ASP.NET in Study4
Angular.js & ASP.NET in Study4Kyle Shen
 
TypeScript 開發實戰:開發即時互動的 html5 websocket 聊天室應用程式
TypeScript 開發實戰:開發即時互動的 html5 websocket 聊天室應用程式TypeScript 開發實戰:開發即時互動的 html5 websocket 聊天室應用程式
TypeScript 開發實戰:開發即時互動的 html5 websocket 聊天室應用程式Will Huang
 

What's hot (20)

ModernWeb 2017 angular component
ModernWeb 2017 angular componentModernWeb 2017 angular component
ModernWeb 2017 angular component
 
AngularJS training in Luster
AngularJS training in LusterAngularJS training in Luster
AngularJS training in Luster
 
保哥線上講堂:利用 StyleCop 撰寫一致的 C# 程式碼風格
保哥線上講堂:利用 StyleCop 撰寫一致的 C# 程式碼風格保哥線上講堂:利用 StyleCop 撰寫一致的 C# 程式碼風格
保哥線上講堂:利用 StyleCop 撰寫一致的 C# 程式碼風格
 
快快樂樂學 Angular 2 開發框架
快快樂樂學 Angular 2 開發框架快快樂樂學 Angular 2 開發框架
快快樂樂學 Angular 2 開發框架
 
進擊的前端工程師:今天就用 JSON Server 自己打造 API 吧!
進擊的前端工程師:今天就用 JSON Server 自己打造 API 吧!進擊的前端工程師:今天就用 JSON Server 自己打造 API 吧!
進擊的前端工程師:今天就用 JSON Server 自己打造 API 吧!
 
使用 ASP.NET 5 實戰開發雲端應用程式
使用 ASP.NET 5 實戰開發雲端應用程式使用 ASP.NET 5 實戰開發雲端應用程式
使用 ASP.NET 5 實戰開發雲端應用程式
 
DEV305 - ASP.NET 5 開發攻略
DEV305 - ASP.NET 5 開發攻略DEV305 - ASP.NET 5 開發攻略
DEV305 - ASP.NET 5 開發攻略
 
ASP.NET 5 的創新與變革
ASP.NET 5 的創新與變革ASP.NET 5 的創新與變革
ASP.NET 5 的創新與變革
 
使用 TypeScript 駕馭 Web 世界的脫韁野馬:以 Angular 2 開發框架為例
使用 TypeScript 駕馭 Web 世界的脫韁野馬:以 Angular 2 開發框架為例使用 TypeScript 駕馭 Web 世界的脫韁野馬:以 Angular 2 開發框架為例
使用 TypeScript 駕馭 Web 世界的脫韁野馬:以 Angular 2 開發框架為例
 
Azure Web App on Linux @ Global Azure Bootcamp 2017 Taiwan
Azure Web App on Linux @ Global Azure Bootcamp 2017 TaiwanAzure Web App on Linux @ Global Azure Bootcamp 2017 Taiwan
Azure Web App on Linux @ Global Azure Bootcamp 2017 Taiwan
 
Frontend Devops at Cloudinsight
Frontend Devops at CloudinsightFrontend Devops at Cloudinsight
Frontend Devops at Cloudinsight
 
React.js what do you really mean?
React.js what do you really mean?React.js what do you really mean?
React.js what do you really mean?
 
改善 Angular 開發流程:你所不知道的 Schematics 程式碼產生器
改善 Angular 開發流程:你所不知道的 Schematics 程式碼產生器改善 Angular 開發流程:你所不知道的 Schematics 程式碼產生器
改善 Angular 開發流程:你所不知道的 Schematics 程式碼產生器
 
Angular js twmvc#17
Angular js twmvc#17Angular js twmvc#17
Angular js twmvc#17
 
宅學習 Firebase
宅學習 Firebase宅學習 Firebase
宅學習 Firebase
 
ASP.NET MVC 6 新功能探索
ASP.NET MVC 6 新功能探索ASP.NET MVC 6 新功能探索
ASP.NET MVC 6 新功能探索
 
AKS 與開發人員體驗 (Kubernetes 大講堂)
AKS 與開發人員體驗 (Kubernetes 大講堂)AKS 與開發人員體驗 (Kubernetes 大講堂)
AKS 與開發人員體驗 (Kubernetes 大講堂)
 
使用 Angular 2 與 Firebase 實現 Serverless 網站架構 (JSDC.tw 2016)
使用 Angular 2 與 Firebase 實現 Serverless 網站架構 (JSDC.tw 2016)使用 Angular 2 與 Firebase 實現 Serverless 網站架構 (JSDC.tw 2016)
使用 Angular 2 與 Firebase 實現 Serverless 網站架構 (JSDC.tw 2016)
 
Angular.js & ASP.NET in Study4
Angular.js & ASP.NET in Study4Angular.js & ASP.NET in Study4
Angular.js & ASP.NET in Study4
 
TypeScript 開發實戰:開發即時互動的 html5 websocket 聊天室應用程式
TypeScript 開發實戰:開發即時互動的 html5 websocket 聊天室應用程式TypeScript 開發實戰:開發即時互動的 html5 websocket 聊天室應用程式
TypeScript 開發實戰:開發即時互動的 html5 websocket 聊天室應用程式
 

Similar to Angular 7 全新功能探索 (Angular Taiwan 2018)

Better use angular
Better use angularBetter use angular
Better use angularYanru Li
 
Schematics 實戰
Schematics 實戰Schematics 實戰
Schematics 實戰志龍 陳
 
[2020 .NET Conf] 企業Azure DevOps Service 實際應用架構與秘辛
[2020 .NET Conf] 企業Azure DevOps Service 實際應用架構與秘辛[2020 .NET Conf] 企業Azure DevOps Service 實際應用架構與秘辛
[2020 .NET Conf] 企業Azure DevOps Service 實際應用架構與秘辛Edward Kuo
 
Uliweb设计分享
Uliweb设计分享Uliweb设计分享
Uliweb设计分享modou li
 
twMVC#17 | 使用Angular.js開發大型系統架構
twMVC#17 | 使用Angular.js開發大型系統架構twMVC#17 | 使用Angular.js開發大型系統架構
twMVC#17 | 使用Angular.js開發大型系統架構twMVC
 
Asp.net mvc網站的從無到有
Asp.net mvc網站的從無到有Asp.net mvc網站的從無到有
Asp.net mvc網站的從無到有Wade Huang
 
深入研究 Angular - phoebe pan
深入研究 Angular  - phoebe pan深入研究 Angular  - phoebe pan
深入研究 Angular - phoebe panPhoebe Pan
 
Kissy design
Kissy designKissy design
Kissy designyiming he
 
Single-Page Application Design Principles 101
Single-Page Application Design Principles 101Single-Page Application Design Principles 101
Single-Page Application Design Principles 101Jollen Chen
 
KISSY Editor Design 2
KISSY Editor Design 2KISSY Editor Design 2
KISSY Editor Design 2yiming he
 
ASP.NET Core 2.1設計新思維與新發展
ASP.NET  Core 2.1設計新思維與新發展ASP.NET  Core 2.1設計新思維與新發展
ASP.NET Core 2.1設計新思維與新發展江華 奚
 
系統整合
系統整合系統整合
系統整合麒 王
 
How to ASP.NET MVC4
How to ASP.NET MVC4How to ASP.NET MVC4
How to ASP.NET MVC4Daniel Chou
 
使用kslite支持第三方内容开发
使用kslite支持第三方内容开发使用kslite支持第三方内容开发
使用kslite支持第三方内容开发leneli
 
Real World ASP.NET MVC
Real World ASP.NET MVCReal World ASP.NET MVC
Real World ASP.NET MVCjeffz
 
模糊也是一種美 - 從 BlurHash 探討前後端上傳圖片架構
模糊也是一種美 - 從 BlurHash 探討前後端上傳圖片架構模糊也是一種美 - 從 BlurHash 探討前後端上傳圖片架構
模糊也是一種美 - 從 BlurHash 探討前後端上傳圖片架構Mu Chun Wang
 
ASP.NET Core MVC 2.2從開發到測試 - Development & Unit Testing
ASP.NET Core MVC 2.2從開發到測試 - Development & Unit TestingASP.NET Core MVC 2.2從開發到測試 - Development & Unit Testing
ASP.NET Core MVC 2.2從開發到測試 - Development & Unit Testing江華 奚
 
Angular js 2 概論
Angular js 2 概論Angular js 2 概論
Angular js 2 概論Jou-An Lai
 
Introduction to ASP.NET MVC and MVC 5 Features
Introduction to ASP.NET MVC and MVC 5 FeaturesIntroduction to ASP.NET MVC and MVC 5 Features
Introduction to ASP.NET MVC and MVC 5 FeaturesJeff Chu
 

Similar to Angular 7 全新功能探索 (Angular Taiwan 2018) (20)

Better use angular
Better use angularBetter use angular
Better use angular
 
Schematics 實戰
Schematics 實戰Schematics 實戰
Schematics 實戰
 
[2020 .NET Conf] 企業Azure DevOps Service 實際應用架構與秘辛
[2020 .NET Conf] 企業Azure DevOps Service 實際應用架構與秘辛[2020 .NET Conf] 企業Azure DevOps Service 實際應用架構與秘辛
[2020 .NET Conf] 企業Azure DevOps Service 實際應用架構與秘辛
 
Angularjs
AngularjsAngularjs
Angularjs
 
Uliweb设计分享
Uliweb设计分享Uliweb设计分享
Uliweb设计分享
 
twMVC#17 | 使用Angular.js開發大型系統架構
twMVC#17 | 使用Angular.js開發大型系統架構twMVC#17 | 使用Angular.js開發大型系統架構
twMVC#17 | 使用Angular.js開發大型系統架構
 
Asp.net mvc網站的從無到有
Asp.net mvc網站的從無到有Asp.net mvc網站的從無到有
Asp.net mvc網站的從無到有
 
深入研究 Angular - phoebe pan
深入研究 Angular  - phoebe pan深入研究 Angular  - phoebe pan
深入研究 Angular - phoebe pan
 
Kissy design
Kissy designKissy design
Kissy design
 
Single-Page Application Design Principles 101
Single-Page Application Design Principles 101Single-Page Application Design Principles 101
Single-Page Application Design Principles 101
 
KISSY Editor Design 2
KISSY Editor Design 2KISSY Editor Design 2
KISSY Editor Design 2
 
ASP.NET Core 2.1設計新思維與新發展
ASP.NET  Core 2.1設計新思維與新發展ASP.NET  Core 2.1設計新思維與新發展
ASP.NET Core 2.1設計新思維與新發展
 
系統整合
系統整合系統整合
系統整合
 
How to ASP.NET MVC4
How to ASP.NET MVC4How to ASP.NET MVC4
How to ASP.NET MVC4
 
使用kslite支持第三方内容开发
使用kslite支持第三方内容开发使用kslite支持第三方内容开发
使用kslite支持第三方内容开发
 
Real World ASP.NET MVC
Real World ASP.NET MVCReal World ASP.NET MVC
Real World ASP.NET MVC
 
模糊也是一種美 - 從 BlurHash 探討前後端上傳圖片架構
模糊也是一種美 - 從 BlurHash 探討前後端上傳圖片架構模糊也是一種美 - 從 BlurHash 探討前後端上傳圖片架構
模糊也是一種美 - 從 BlurHash 探討前後端上傳圖片架構
 
ASP.NET Core MVC 2.2從開發到測試 - Development & Unit Testing
ASP.NET Core MVC 2.2從開發到測試 - Development & Unit TestingASP.NET Core MVC 2.2從開發到測試 - Development & Unit Testing
ASP.NET Core MVC 2.2從開發到測試 - Development & Unit Testing
 
Angular js 2 概論
Angular js 2 概論Angular js 2 概論
Angular js 2 概論
 
Introduction to ASP.NET MVC and MVC 5 Features
Introduction to ASP.NET MVC and MVC 5 FeaturesIntroduction to ASP.NET MVC and MVC 5 Features
Introduction to ASP.NET MVC and MVC 5 Features
 

More from Will Huang

深入理解 CVE-2022-24765 漏洞的攻擊與防護策略 (Git v2.35.2)
深入理解 CVE-2022-24765 漏洞的攻擊與防護策略 (Git v2.35.2)深入理解 CVE-2022-24765 漏洞的攻擊與防護策略 (Git v2.35.2)
深入理解 CVE-2022-24765 漏洞的攻擊與防護策略 (Git v2.35.2)Will Huang
 
從頭打造 C#、.NET 與 ASP.NET Core 開發環境
從頭打造 C#、.NET 與 ASP.NET Core 開發環境從頭打造 C#、.NET 與 ASP.NET Core 開發環境
從頭打造 C#、.NET 與 ASP.NET Core 開發環境Will Huang
 
你一定不能不知道的 Markdown 寫作技巧
你一定不能不知道的 Markdown 寫作技巧你一定不能不知道的 Markdown 寫作技巧
你一定不能不知道的 Markdown 寫作技巧Will Huang
 
使用 .NET 5 實現美股期貨的量化交易策略 (.NET Conf 2020)
使用 .NET 5 實現美股期貨的量化交易策略 (.NET Conf 2020)使用 .NET 5 實現美股期貨的量化交易策略 (.NET Conf 2020)
使用 .NET 5 實現美股期貨的量化交易策略 (.NET Conf 2020)Will Huang
 
從實戰經驗看到的 K8S 導入痛點
從實戰經驗看到的 K8S 導入痛點從實戰經驗看到的 K8S 導入痛點
從實戰經驗看到的 K8S 導入痛點Will Huang
 
RxJS 6 新手入門
RxJS 6 新手入門RxJS 6 新手入門
RxJS 6 新手入門Will Huang
 
你不可不知的 ASP.NET Core 3 全新功能探索 (.NET Conf 2019)
你不可不知的 ASP.NET Core 3 全新功能探索 (.NET Conf 2019)你不可不知的 ASP.NET Core 3 全新功能探索 (.NET Conf 2019)
你不可不知的 ASP.NET Core 3 全新功能探索 (.NET Conf 2019)Will Huang
 
Protractor: The Hacker way (NG-MY 2019)
Protractor: The Hacker way (NG-MY 2019)Protractor: The Hacker way (NG-MY 2019)
Protractor: The Hacker way (NG-MY 2019)Will Huang
 
邁向 Windows Server 應用程式現代化 (Windows Server Application Modernization)
邁向 Windows Server 應用程式現代化 (Windows Server Application Modernization)邁向 Windows Server 應用程式現代化 (Windows Server Application Modernization)
邁向 Windows Server 應用程式現代化 (Windows Server Application Modernization)Will Huang
 
Angular 开发技巧 (2018 ngChina 开发者大会)
Angular 开发技巧 (2018 ngChina 开发者大会)Angular 开发技巧 (2018 ngChina 开发者大会)
Angular 开发技巧 (2018 ngChina 开发者大会)Will Huang
 
利用.NET Core 與 Azure Kubernetes Service (AKS) 建立高彈性 Microservices (Azure TechDay)
利用.NET Core 與 Azure Kubernetes Service (AKS) 建立高彈性 Microservices (Azure TechDay)利用.NET Core 與 Azure Kubernetes Service (AKS) 建立高彈性 Microservices (Azure TechDay)
利用.NET Core 與 Azure Kubernetes Service (AKS) 建立高彈性 Microservices (Azure TechDay)Will Huang
 
使用 ASP.NET Blazor 開發 SPA 網頁應用程式 (.NET Conf 2018)
使用 ASP.NET Blazor 開發 SPA 網頁應用程式 (.NET Conf 2018)使用 ASP.NET Blazor 開發 SPA 網頁應用程式 (.NET Conf 2018)
使用 ASP.NET Blazor 開發 SPA 網頁應用程式 (.NET Conf 2018)Will Huang
 
全新 Windows Server 2019 容器技術 及邁向與 Kubernetes 整合之路 (Windows Server 高峰會)
全新 Windows Server 2019 容器技術及邁向與 Kubernetes 整合之路 (Windows Server 高峰會)全新 Windows Server 2019 容器技術及邁向與 Kubernetes 整合之路 (Windows Server 高峰會)
全新 Windows Server 2019 容器技術 及邁向與 Kubernetes 整合之路 (Windows Server 高峰會)Will Huang
 
使用 C#/Razor 開發互動式 WebAssembly 網站 (Modern Web 2018)
使用 C#/Razor 開發互動式 WebAssembly 網站 (Modern Web 2018)使用 C#/Razor 開發互動式 WebAssembly 網站 (Modern Web 2018)
使用 C#/Razor 開發互動式 WebAssembly 網站 (Modern Web 2018)Will Huang
 
以敏捷架構打造美國軟體外包專案的經驗談
以敏捷架構打造美國軟體外包專案的經驗談以敏捷架構打造美國軟體外包專案的經驗談
以敏捷架構打造美國軟體外包專案的經驗談Will Huang
 
開發人員必須知道的 Kubernetes 核心技術 - Kubernetes Summit 2018
開發人員必須知道的 Kubernetes 核心技術 - Kubernetes Summit 2018開發人員必須知道的 Kubernetes 核心技術 - Kubernetes Summit 2018
開發人員必須知道的 Kubernetes 核心技術 - Kubernetes Summit 2018Will Huang
 
迎接嶄新的Windows容器叢集架構:Kubernetes
迎接嶄新的Windows容器叢集架構:Kubernetes迎接嶄新的Windows容器叢集架構:Kubernetes
迎接嶄新的Windows容器叢集架構:KubernetesWill Huang
 
TypeScript 綜合格鬥技
TypeScript 綜合格鬥技TypeScript 綜合格鬥技
TypeScript 綜合格鬥技Will Huang
 
Windows Container 101: dotNET, Container, Kubernetes
Windows Container 101: dotNET, Container, KubernetesWindows Container 101: dotNET, Container, Kubernetes
Windows Container 101: dotNET, Container, KubernetesWill Huang
 
申請 Let's Encrypt 免費 SSL 憑證一次就上手
申請 Let's Encrypt 免費 SSL 憑證一次就上手申請 Let's Encrypt 免費 SSL 憑證一次就上手
申請 Let's Encrypt 免費 SSL 憑證一次就上手Will Huang
 

More from Will Huang (20)

深入理解 CVE-2022-24765 漏洞的攻擊與防護策略 (Git v2.35.2)
深入理解 CVE-2022-24765 漏洞的攻擊與防護策略 (Git v2.35.2)深入理解 CVE-2022-24765 漏洞的攻擊與防護策略 (Git v2.35.2)
深入理解 CVE-2022-24765 漏洞的攻擊與防護策略 (Git v2.35.2)
 
從頭打造 C#、.NET 與 ASP.NET Core 開發環境
從頭打造 C#、.NET 與 ASP.NET Core 開發環境從頭打造 C#、.NET 與 ASP.NET Core 開發環境
從頭打造 C#、.NET 與 ASP.NET Core 開發環境
 
你一定不能不知道的 Markdown 寫作技巧
你一定不能不知道的 Markdown 寫作技巧你一定不能不知道的 Markdown 寫作技巧
你一定不能不知道的 Markdown 寫作技巧
 
使用 .NET 5 實現美股期貨的量化交易策略 (.NET Conf 2020)
使用 .NET 5 實現美股期貨的量化交易策略 (.NET Conf 2020)使用 .NET 5 實現美股期貨的量化交易策略 (.NET Conf 2020)
使用 .NET 5 實現美股期貨的量化交易策略 (.NET Conf 2020)
 
從實戰經驗看到的 K8S 導入痛點
從實戰經驗看到的 K8S 導入痛點從實戰經驗看到的 K8S 導入痛點
從實戰經驗看到的 K8S 導入痛點
 
RxJS 6 新手入門
RxJS 6 新手入門RxJS 6 新手入門
RxJS 6 新手入門
 
你不可不知的 ASP.NET Core 3 全新功能探索 (.NET Conf 2019)
你不可不知的 ASP.NET Core 3 全新功能探索 (.NET Conf 2019)你不可不知的 ASP.NET Core 3 全新功能探索 (.NET Conf 2019)
你不可不知的 ASP.NET Core 3 全新功能探索 (.NET Conf 2019)
 
Protractor: The Hacker way (NG-MY 2019)
Protractor: The Hacker way (NG-MY 2019)Protractor: The Hacker way (NG-MY 2019)
Protractor: The Hacker way (NG-MY 2019)
 
邁向 Windows Server 應用程式現代化 (Windows Server Application Modernization)
邁向 Windows Server 應用程式現代化 (Windows Server Application Modernization)邁向 Windows Server 應用程式現代化 (Windows Server Application Modernization)
邁向 Windows Server 應用程式現代化 (Windows Server Application Modernization)
 
Angular 开发技巧 (2018 ngChina 开发者大会)
Angular 开发技巧 (2018 ngChina 开发者大会)Angular 开发技巧 (2018 ngChina 开发者大会)
Angular 开发技巧 (2018 ngChina 开发者大会)
 
利用.NET Core 與 Azure Kubernetes Service (AKS) 建立高彈性 Microservices (Azure TechDay)
利用.NET Core 與 Azure Kubernetes Service (AKS) 建立高彈性 Microservices (Azure TechDay)利用.NET Core 與 Azure Kubernetes Service (AKS) 建立高彈性 Microservices (Azure TechDay)
利用.NET Core 與 Azure Kubernetes Service (AKS) 建立高彈性 Microservices (Azure TechDay)
 
使用 ASP.NET Blazor 開發 SPA 網頁應用程式 (.NET Conf 2018)
使用 ASP.NET Blazor 開發 SPA 網頁應用程式 (.NET Conf 2018)使用 ASP.NET Blazor 開發 SPA 網頁應用程式 (.NET Conf 2018)
使用 ASP.NET Blazor 開發 SPA 網頁應用程式 (.NET Conf 2018)
 
全新 Windows Server 2019 容器技術 及邁向與 Kubernetes 整合之路 (Windows Server 高峰會)
全新 Windows Server 2019 容器技術及邁向與 Kubernetes 整合之路 (Windows Server 高峰會)全新 Windows Server 2019 容器技術及邁向與 Kubernetes 整合之路 (Windows Server 高峰會)
全新 Windows Server 2019 容器技術 及邁向與 Kubernetes 整合之路 (Windows Server 高峰會)
 
使用 C#/Razor 開發互動式 WebAssembly 網站 (Modern Web 2018)
使用 C#/Razor 開發互動式 WebAssembly 網站 (Modern Web 2018)使用 C#/Razor 開發互動式 WebAssembly 網站 (Modern Web 2018)
使用 C#/Razor 開發互動式 WebAssembly 網站 (Modern Web 2018)
 
以敏捷架構打造美國軟體外包專案的經驗談
以敏捷架構打造美國軟體外包專案的經驗談以敏捷架構打造美國軟體外包專案的經驗談
以敏捷架構打造美國軟體外包專案的經驗談
 
開發人員必須知道的 Kubernetes 核心技術 - Kubernetes Summit 2018
開發人員必須知道的 Kubernetes 核心技術 - Kubernetes Summit 2018開發人員必須知道的 Kubernetes 核心技術 - Kubernetes Summit 2018
開發人員必須知道的 Kubernetes 核心技術 - Kubernetes Summit 2018
 
迎接嶄新的Windows容器叢集架構:Kubernetes
迎接嶄新的Windows容器叢集架構:Kubernetes迎接嶄新的Windows容器叢集架構:Kubernetes
迎接嶄新的Windows容器叢集架構:Kubernetes
 
TypeScript 綜合格鬥技
TypeScript 綜合格鬥技TypeScript 綜合格鬥技
TypeScript 綜合格鬥技
 
Windows Container 101: dotNET, Container, Kubernetes
Windows Container 101: dotNET, Container, KubernetesWindows Container 101: dotNET, Container, Kubernetes
Windows Container 101: dotNET, Container, Kubernetes
 
申請 Let's Encrypt 免費 SSL 憑證一次就上手
申請 Let's Encrypt 免費 SSL 憑證一次就上手申請 Let's Encrypt 免費 SSL 憑證一次就上手
申請 Let's Encrypt 免費 SSL 憑證一次就上手
 

Angular 7 全新功能探索 (Angular Taiwan 2018)

  • 2. 本日大綱 • Angular CLI v7 • Angular Material / CDK • Angular Elements • The Ivy Render Engine • ng update • Breaking Changes
  • 4. 全新的 ng new / ng add 互動式介面 ng new demo1 --routing --style css
  • 6. ng generate component • /angular/angular-cli/.../schematics/angular/component/schema.json#L21-L29
  • 7. 全新的 Angular CLI 官方文件 • https://angular.io/cli • CLI Command Reference • 使用說明已整合進 angular.io 官方網站
  • 8. 更小的 bundle size 推出 • Angular v6 以前,預設會從 srcpolyfills.ts 載入 reflect-metadata 套件 import 'core-js/es7/reflect'; • 但是預設 reflect-metadata 套件只會在 JIT 模式使用到 • 大部分 Angular 網站都是以 AOT 模式編譯執行,所以不需要載入這個套件! • 從 Angular CLI v7 開始,會 全自動判斷 何時該載入這個 Polyfills!
  • 9. Angular CLI 6: 載入 core-js/es7/reflect 模組
  • 10. Angular CLI 7: 移除 core-js/es7/reflect 模組 大約差2/3 個 jQuery 大小 (20.7 KB)
  • 11. 正式推出 Bundle Budgets 功能 angular.json
  • 14. 示範錯誤的 rxjs 匯入方式 • 為了 RxJS 舊版的相容性,你在升級時可能會安裝 rxjs-compat npm install rxjs-compat • 早期不太好的匯入方式 import 'rxjs/Rx'; • 解決方案 • 設定 tslint.json 的 "import-blacklist" 匯入黑名單 • ng lint
  • 15. Angular Material 與 CDK 全新功能:虛擬捲動 與 拖曳功能
  • 16. 虛擬捲動 (Virtual Scrolling) • 匯入 ScrollingModule 模組 • https://material.angular.io/cdk/scrolling/overview • PrimeNG 也正是內建 VirtualScroller ( 內建延遲載入、排序、篩選 ) https://twitter.com/cagataycivici/status/1063031348745650176
  • 17. 拖曳功能 (Drag and Drop) • 匯入 DragDropModule 模組 • https://material.angular.io/cdk/drag-drop/overview
  • 18. 下拉選單 ( select / mat-form-field ) • 允許在 <mat-form-field> 標籤中使用 HTML 原生的 <select> 標籤 • https://material.angular.io/components/select/overview
  • 20. Angular Elements 是什麼? • https://angular.io/guide/elements ( 中文版 ) • 能將 Angular 元件封裝成 自訂元素 (Custom elements) • 自訂元素 可以執行在 Chrome, Opera, 與 Safari 瀏覽器 (Edge?) (相容性) • 推薦影片:Elements in v6 and Beyond - Rob Wormald • Upgrading With Web Components: From AngularJS To Angular
  • 21. Angular Elements 運作原理 1. 將自訂元素註冊至瀏覽器 2. 將自訂元素加入 DOM 3. 初始化自訂元素 4. 事件繫結 & 變更偵測
  • 22. Angular Elements 起手式 • 文章:A Practical Guide to Angular Elements • 範例:https://stackblitz.com/edit/angular-elements-official-example • 設定步驟 ( ng new demo1 --routing false --style css ) 1. 安裝 @angular/elements 套件 • ng add @angular/elements 2. 修改 tsconfig.json • "target": "es2015", 3. 撰寫 Angular 元件 • ng g c made-with-love -v ShadowDom 4. 修改 src/angular.module.ts • 刪除 AppComponent 元件 / 刪除 bootstrap 屬性 / 新增 ngDoBootstrap() 方法 • 新增 entryComponents 屬性並加入 MadeWithLoveComponent 元件 • import { createCustomElement } from '@angular/elements'; • 建立 constructor() 建構式並透過 createCustomElement() 建立自訂元素
  • 23. 可使用 <slot> 標籤 (content projection) • 可以在自訂元素中使用自訂內容 (content) • 可在自訂元素中使用 Web Components 標準的 <slot> 標籤 • Angular 6 範例 (Stackblitz) / Angular 7 範例 (Stackblitz) <made-with-love name="Will" url="https://blog.miniasp.com"> <span slot="my-header">Header<hr></span> <h1>OK</h1> <span slot="my-footer"><hr>Footer</span> </made-with-love> <header> <slot name="my-header"></slot> <slot name="my-footer"></slot> </header>
  • 24. The Ivy Render Engine 劃時代的 Angular 渲染引擎
  • 25. 搶先體驗 Ivy 渲染引擎 • 免安裝立即體驗 npx @angular/cli@next new demo7-ivy --experimental-ivy --style css --routing • 以 production 環境進行建置 ng serve --prod ng build --prod • 目前僅能在 macOS 環境下成功建置!
  • 27. 最新 Ivy 發展進度:93.96% • Ivy status • AngularEvolution • Is Angular Ivy Ready • Design Doc (Ivy)
  • 29. 更新與升級 Angular 應用程式 • https://update.angular.io/ • 更新過時的 rxjs 寫法 npm install -g rxjs-tslint rxjs-5-to-6-migrate -p src/tsconfig.app.json npm uninstall rxjs-compat • 更新到 Angular v7 ng update @angular/cli @angular/core ng update @angular/material
  • 30. 取得 Angular 版本資訊 • 查詢目前專案的 Angular CLI 版本 • ng version ( 早期的 ng -v 現在已經棄用 ) • 查詢 @angular/cli 套件的最新版本 • npm info @angular/cli dist-tags
  • 32. 關於破壞性更新的幾點提醒 • Angular v6:表單元素 <ngForm> 已棄用,請改用 <ng-form> 或繼續用 <form> 即可 • 預計 Angular v9 (2019-11) 會移除 <ngForm> 這種用法! • Angular v6:雙向繫結的 [(ngModel)] 不要跟 Reactive Forms 的寫法一起使用 • <input [formControl]="control" [(ngModel)]="value"> • 預計 Angular v7 會移除這種使用方式,升級前請先行調整寫法! • Angular v4:不要再用 <template> 標籤,改用 <ng-template> 為主!
  • 33. Q & A
  • 34. 相關連結 • Version 7 of Angular — CLI Prompts, Virtual Scroll, Drag and Drop and more • Angular CLI Command Reference • How Did Angular CLI Budgets Save My Day And How They Can Save Yours • Angular Elements Overview • Is Angular Ivy Ready • Angular Update Guide

Editor's Notes

  1. Try latest Angular CLI Beta / RC, with Angular v7 and the new Ivy compiler, no install required thanks to npm and npx https://www.gurustop.net/blog/2018/10/11/4258/npm-npx-angular-beta-rc-next-angular-cli-ivy-compiler
  2. How Did Angular CLI Budgets Save My Day And How They Can Save Yours https://medium.com/dailyjs/how-did-angular-cli-budgets-save-my-day-and-how-they-can-save-yours-300d534aae7a
  3. [Bug] angular/elements: Failed to construct 'HTMLElement': Please use the 'new' operator · Issue #24556 · angular/angular https://github.com/angular/angular/issues/24556
  4. Angular 6 Example: https://stackblitz.com/edit/angular-elements-official-example-onmjxi?file=index.html Angular 7 Example: https://stackblitz.com/edit/angular-elements-example-with-slot?file=src%2Findex.html ng-content, slot and content elements don't work with nested Angular custom elements · Issue #24536 · angular/angular https://github.com/angular/angular/issues/24536 Add support for Shadow DOM V1 · Issue #23636 · angular/angular https://github.com/angular/angular/issues/23636
  5. https://github.com/angular/angular/blob/master/CHANGELOG.md