SlideShare une entreprise Scribd logo
1  sur  18
Télécharger pour lire hors ligne
Taipei
Mike Huang
多奇數位創意有限公司
使用 Standalone Component
來寫 Angular 吧!
About Me
● Title
○ 多奇數位創意有限公司
○ Angular GDE
○ Microsoft MVP
● Awards
○ 2018 iT 邦幫忙鐵人賽 冠軍
○ 2019 iT 邦幫忙鐵人賽 優選
○ 第 12 屆 iThome 鐵人賽 冠軍
● 著作:打通 RxJS 任督二脈
https://github.com/wellwind
https://www.facebook.com/fullstackledder
https://fullstackladder.dev
https://www.tenlong.com.tw/products/9789864348039
先回憶一下使用
@NgModule 的感覺
@NgModule({
declarations: [
AppComponent,
LayoutComponent
],
imports: [
BrowserModule,
AnotherModule,
TodoListModule
],
providers: [ ],
bootstrap: [AppComponent]
})
export class AppModule { }
@NgModule({
declarations: [
TodoListComponent,
TodoItemComponent,
TodoTextPipe,
TodoDoneDirective
],
imports: [
CommonModule
],
exports: [
TodoListComponent
]
})
export class TodoListModule { }
@Component({
selector: 'app-root',
template: '<app-todo-list></app-todo-list>'
})
export class AppComponent { }
如何找到 <app-todo-list></app-todo-list> 元件?
@Component({
selector: 'app-root',
template: '<app-todo-list></app-todo-list>'
})
export class AppComponent { }
如何找到 <app-todo-list></app-todo-list> 元件?
@NgModule({
declarations: [
AppComponent,
LayoutComponent
],
imports: [
BrowserModule,
AnotherModule,
TodoListModule
],
providers: [ ],
bootstrap: [AppComponent]
})
export class AppModule { }
1
2
@NgModule({
declarations: [
TodoListComponent,
TodoItemComponent,
TodoTextPipe,
TodoDoneDirective
],
imports: [
CommonModule
],
exports: [
TodoListComponent
]
})
export class TodoListModule { }
3
4
Angular Standalone
Components / Directives / Pipes
Standalone Components / Directives / Pipes
● Angular 14 推出 Developer Preview
● Angular 15 正式宣告 stable
● 在 @Component、@Directive、@Pipe 加上 standalone: true 即可!
● Standalone 程式本身即可用 imports: [] 匯入
○ 其他的 @NgModule
○ 其他的 Standalone 程式
● 有 @NgModule 的概念,但又不用管 @NgModule
● 更加直覺、簡單的開發方式
● 打包速度更快、產出檔案更小
@Component({
standalone: true,
selector: 'app-root',
...
})
export class AppComponent { }
• 加上 standalone: true 就對了!
• 在 @Directive / @Pipe 上一樣適用
@Component({
standalone: true,
selector: 'app-todo-list',
imports: [
CommonModule
],
template: `
<ul *ngFor="...">
<li>...</li>
</ul>
`
})
export class TodoListComponent { }
@Component({
standalone: true,
selector: 'app-root',
...
})
export class AppComponent { }
準備一個 standalone component
ng generate component [name] --standalone
imports: [] 可加入其他 @NgModule
@Component({
standalone: true,
selector: 'app-root',
imports: [
NgIf
TodoListComponent
],
template: `
<app-todo-list>
</app-todo-list>
`
})
export class AppComponent { }
@Component({
standalone: true,
selector: 'app-todo-list',
imports: [
CommonModule
],
template: `
<ul *ngFor="...">
<li>...</li>
</ul>
`
})
export class TodoListComponent { }
NgIf、NgFor 等 directives 現在也都是 standalone 了!
@Component({
standalone: true,
selector: 'app-root',
imports: [
TodoListComponent
],
template: `
<app-todo-list>
</app-todo-list>
`
})
export class AppComponent { }
@Component({
standalone: true,
selector: 'app-todo-list',
imports: [
CommonModule
],
template: `
<ul *ngFor="...">
<li>...</li>
</ul>
`
})
export class TodoListComponent { }
standalone component 可以放入
另外一個 standalone component 的 imoprts: [] 中
@Component({
standalone: true,
selector: 'app-root',
imports: [
NgIf,
TodoListComponent
],
template: `
<app-todo-list *ngIf="...">
</app-todo-list>
`
})
export class AppComponent { }
如何找到 <app-todo-list></app-todo-list> 元件?
1 抬頭就找到!
需要什麼再匯入什麼
就。很。剛剛好。
更多重點都在文件裡
https://angular.io/guide/standalone-components
DEMO
Resources
● 搶先體驗 Standalone Components / Directives / Pipes
● RFC: Standalone APIs
● Getting started with standalone components

Contenu connexe

Tendances

T90 きっと怖くないmvvm & mvpvm
T90 きっと怖くないmvvm & mvpvmT90 きっと怖くないmvvm & mvpvm
T90 きっと怖くないmvvm & mvpvm
伸男 伊藤
 
そんなトランザクションマネージャで大丈夫か?
そんなトランザクションマネージャで大丈夫か?そんなトランザクションマネージャで大丈夫か?
そんなトランザクションマネージャで大丈夫か?
takezoe
 

Tendances (20)

Riverpodでテストを書こう
Riverpodでテストを書こうRiverpodでテストを書こう
Riverpodでテストを書こう
 
コードの自動修正によって実現する、機能開発を止めないフレームワーク移行
コードの自動修正によって実現する、機能開発を止めないフレームワーク移行コードの自動修正によって実現する、機能開発を止めないフレームワーク移行
コードの自動修正によって実現する、機能開発を止めないフレームワーク移行
 
DynamoDBによるソーシャルゲーム実装 How To
DynamoDBによるソーシャルゲーム実装 How ToDynamoDBによるソーシャルゲーム実装 How To
DynamoDBによるソーシャルゲーム実装 How To
 
Laravel × レイヤードアーキテクチャを実践して得られた知見と反省 / Practice of Laravel with layered archi...
Laravel × レイヤードアーキテクチャを実践して得られた知見と反省 / Practice of Laravel with layered archi...Laravel × レイヤードアーキテクチャを実践して得られた知見と反省 / Practice of Laravel with layered archi...
Laravel × レイヤードアーキテクチャを実践して得られた知見と反省 / Practice of Laravel with layered archi...
 
T90 きっと怖くないmvvm & mvpvm
T90 きっと怖くないmvvm & mvpvmT90 きっと怖くないmvvm & mvpvm
T90 きっと怖くないmvvm & mvpvm
 
そんなトランザクションマネージャで大丈夫か?
そんなトランザクションマネージャで大丈夫か?そんなトランザクションマネージャで大丈夫か?
そんなトランザクションマネージャで大丈夫か?
 
Capabilities for Resources and Effects
Capabilities for Resources and EffectsCapabilities for Resources and Effects
Capabilities for Resources and Effects
 
hooks riverpod + state notifier + freezed でのドメイン駆動設計
hooks riverpod + state notifier + freezed でのドメイン駆動設計hooks riverpod + state notifier + freezed でのドメイン駆動設計
hooks riverpod + state notifier + freezed でのドメイン駆動設計
 
So You Want to Write a Connector?
So You Want to Write a Connector? So You Want to Write a Connector?
So You Want to Write a Connector?
 
traitを使って楽したい話
traitを使って楽したい話traitを使って楽したい話
traitを使って楽したい話
 
導入から 10 年、PHP の trait は滅びるべきなのか その適切な使いどころと弱点、将来について
導入から 10 年、PHP の trait は滅びるべきなのか その適切な使いどころと弱点、将来について導入から 10 年、PHP の trait は滅びるべきなのか その適切な使いどころと弱点、将来について
導入から 10 年、PHP の trait は滅びるべきなのか その適切な使いどころと弱点、将来について
 
Djangoフレームワークのユーザーモデルと認証
Djangoフレームワークのユーザーモデルと認証Djangoフレームワークのユーザーモデルと認証
Djangoフレームワークのユーザーモデルと認証
 
リアルタイムサーバー 〜Erlang/OTPで作るPubSubサーバー〜
リアルタイムサーバー 〜Erlang/OTPで作るPubSubサーバー〜 リアルタイムサーバー 〜Erlang/OTPで作るPubSubサーバー〜
リアルタイムサーバー 〜Erlang/OTPで作るPubSubサーバー〜
 
HTTP/2で 速くなるとき ならないとき
HTTP/2で 速くなるとき ならないときHTTP/2で 速くなるとき ならないとき
HTTP/2で 速くなるとき ならないとき
 
Dockerを支える技術
Dockerを支える技術Dockerを支える技術
Dockerを支える技術
 
バグ0の資産を積み上げるための証明駆動開発入門
バグ0の資産を積み上げるための証明駆動開発入門バグ0の資産を積み上げるための証明駆動開発入門
バグ0の資産を積み上げるための証明駆動開発入門
 
はじめてのプロジェクト管理ツール 〜Redmine超入門〜
はじめてのプロジェクト管理ツール  〜Redmine超入門〜はじめてのプロジェクト管理ツール  〜Redmine超入門〜
はじめてのプロジェクト管理ツール 〜Redmine超入門〜
 
DockerコンテナでGitを使う
DockerコンテナでGitを使うDockerコンテナでGitを使う
DockerコンテナでGitを使う
 
世界一わかりやすいClean Architecture
世界一わかりやすいClean Architecture世界一わかりやすいClean Architecture
世界一わかりやすいClean Architecture
 
これで怖くない!?コードリーディングで学ぶSpring Security #中央線Meetup
これで怖くない!?コードリーディングで学ぶSpring Security #中央線Meetupこれで怖くない!?コードリーディングで学ぶSpring Security #中央線Meetup
これで怖くない!?コードリーディングで学ぶSpring Security #中央線Meetup
 

Similaire à DevFest 2022 Taipei 使用 Standalone Component 來寫 Angular 吧!

From SQLAlchemy to Ming with TurboGears2
From SQLAlchemy to Ming with TurboGears2From SQLAlchemy to Ming with TurboGears2
From SQLAlchemy to Ming with TurboGears2
Alessandro Molina
 
Introduction to Gradio library in python.pptx
Introduction to Gradio library in python.pptxIntroduction to Gradio library in python.pptx
Introduction to Gradio library in python.pptx
vahid67ebrahimian
 

Similaire à DevFest 2022 Taipei 使用 Standalone Component 來寫 Angular 吧! (20)

PyconIE 2016 - Kajiki, the fast and validated template engine your were looki...
PyconIE 2016 - Kajiki, the fast and validated template engine your were looki...PyconIE 2016 - Kajiki, the fast and validated template engine your were looki...
PyconIE 2016 - Kajiki, the fast and validated template engine your were looki...
 
Bootiful Development with Spring Boot and Angular - RWX 2018
Bootiful Development with Spring Boot and Angular - RWX 2018Bootiful Development with Spring Boot and Angular - RWX 2018
Bootiful Development with Spring Boot and Angular - RWX 2018
 
Advanced Dagger talk from 360andev
Advanced Dagger talk from 360andevAdvanced Dagger talk from 360andev
Advanced Dagger talk from 360andev
 
2016 stop writing javascript frameworks by Joe Gregorio
2016 stop writing javascript frameworks by Joe Gregorio2016 stop writing javascript frameworks by Joe Gregorio
2016 stop writing javascript frameworks by Joe Gregorio
 
Intro to meteor @py gotham Aug 15-16 2015
Intro to meteor @py gotham Aug 15-16 2015Intro to meteor @py gotham Aug 15-16 2015
Intro to meteor @py gotham Aug 15-16 2015
 
angular2.0
angular2.0angular2.0
angular2.0
 
Creando microservicios con java micro profile y tomee - CUNORI 2020
Creando microservicios con java micro profile y tomee - CUNORI 2020Creando microservicios con java micro profile y tomee - CUNORI 2020
Creando microservicios con java micro profile y tomee - CUNORI 2020
 
Standardizing JavaScript Decorators in TC39 (Full Stack Fest 2019)
Standardizing JavaScript Decorators in TC39 (Full Stack Fest 2019)Standardizing JavaScript Decorators in TC39 (Full Stack Fest 2019)
Standardizing JavaScript Decorators in TC39 (Full Stack Fest 2019)
 
From SQLAlchemy to Ming with TurboGears2
From SQLAlchemy to Ming with TurboGears2From SQLAlchemy to Ming with TurboGears2
From SQLAlchemy to Ming with TurboGears2
 
vodQA Pune (2019) - Design patterns in test automation
vodQA Pune (2019) - Design patterns in test automationvodQA Pune (2019) - Design patterns in test automation
vodQA Pune (2019) - Design patterns in test automation
 
Front End Development for Back End Developers - UberConf 2017
Front End Development for Back End Developers - UberConf 2017Front End Development for Back End Developers - UberConf 2017
Front End Development for Back End Developers - UberConf 2017
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to Django
 
Paving the road with Jakarta EE and Apache TomEE - JCON 2021
Paving the road with Jakarta EE  and Apache TomEE - JCON 2021Paving the road with Jakarta EE  and Apache TomEE - JCON 2021
Paving the road with Jakarta EE and Apache TomEE - JCON 2021
 
Front end microservices - October 2019
Front end microservices - October 2019Front end microservices - October 2019
Front end microservices - October 2019
 
Big data101kagglepresentation
Big data101kagglepresentationBig data101kagglepresentation
Big data101kagglepresentation
 
Angular 2: What's New?
Angular 2: What's New?Angular 2: What's New?
Angular 2: What's New?
 
Introduction to Gradio library in python.pptx
Introduction to Gradio library in python.pptxIntroduction to Gradio library in python.pptx
Introduction to Gradio library in python.pptx
 
Mock with Mockito
Mock with MockitoMock with Mockito
Mock with Mockito
 
Itsjustangular
ItsjustangularItsjustangular
Itsjustangular
 
Grails & Angular: unleashing the dynamic duo
Grails & Angular: unleashing the dynamic duoGrails & Angular: unleashing the dynamic duo
Grails & Angular: unleashing the dynamic duo
 

Plus de 升煌 黃

Plus de 升煌 黃 (14)

使用 Passkeys 打造無密碼驗證服務
使用 Passkeys 打造無密碼驗證服務使用 Passkeys 打造無密碼驗證服務
使用 Passkeys 打造無密碼驗證服務
 
陽明交大 - 跟著 AI 學習 Angular
陽明交大 - 跟著 AI 學習 Angular陽明交大 - 跟著 AI 學習 Angular
陽明交大 - 跟著 AI 學習 Angular
 
.NET Conf Taiwan 2022 - Tauri - 前端人員也能打造小巧快速的 Windows 應用程式
.NET Conf Taiwan 2022 - Tauri -前端人員也能打造小巧快速的 Windows 應用程式.NET Conf Taiwan 2022 - Tauri -前端人員也能打造小巧快速的 Windows 應用程式
.NET Conf Taiwan 2022 - Tauri - 前端人員也能打造小巧快速的 Windows 應用程式
 
gRPC - 打造輕量、高效能的後端服務
gRPC - 打造輕量、高效能的後端服務gRPC - 打造輕量、高效能的後端服務
gRPC - 打造輕量、高效能的後端服務
 
Modern web 2020 - 使用 Nx 管理超大型前後端專案
Modern web 2020 - 使用 Nx 管理超大型前後端專案Modern web 2020 - 使用 Nx 管理超大型前後端專案
Modern web 2020 - 使用 Nx 管理超大型前後端專案
 
Angular Taiwan 2019 - Schematics Workshop
Angular Taiwan 2019 - Schematics WorkshopAngular Taiwan 2019 - Schematics Workshop
Angular Taiwan 2019 - Schematics Workshop
 
Angular Taiwan 2019 - 大型 Angular 專案的的管理心得與技巧
Angular Taiwan 2019 - 大型 Angular 專案的的管理心得與技巧Angular Taiwan 2019 - 大型 Angular 專案的的管理心得與技巧
Angular Taiwan 2019 - 大型 Angular 專案的的管理心得與技巧
 
Angular Meetup 04 - Angular PWA 之沒有網路的日子 20190731
Angular Meetup 04 - Angular PWA 之沒有網路的日子 20190731Angular Meetup 04 - Angular PWA 之沒有網路的日子 20190731
Angular Meetup 04 - Angular PWA 之沒有網路的日子 20190731
 
Angular Taiwan 2018 - Angular CDK
Angular Taiwan 2018 - Angular CDKAngular Taiwan 2018 - Angular CDK
Angular Taiwan 2018 - Angular CDK
 
玩轉 Schematics - Modern Web 2018
玩轉 Schematics - Modern Web 2018玩轉 Schematics - Modern Web 2018
玩轉 Schematics - Modern Web 2018
 
OAuth2介紹
OAuth2介紹OAuth2介紹
OAuth2介紹
 
Docker - 30秒生出100台伺服器
Docker - 30秒生出100台伺服器Docker - 30秒生出100台伺服器
Docker - 30秒生出100台伺服器
 
敏捷開發與Scrum
敏捷開發與Scrum敏捷開發與Scrum
敏捷開發與Scrum
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 

Dernier

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Dernier (20)

ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 

DevFest 2022 Taipei 使用 Standalone Component 來寫 Angular 吧!