SlideShare a Scribd company logo
1 of 16
Understand Data Binding
Cao Duy Khanh
Points
What is Data Binding
Two-Way vs One-Time Binding
Demos & QA
Background
Tool Age DOM manipulation tool like JQuery
Bronze Age Client-side templating tool like Mustache, Handlebars.js
Iron Age Angular, React
How we develop a web app
Before
1. HTML that defines your page
2. Get necessary data by AJAX
3. Client side templating (Script hack:
<script type="text/html">...</script>)
4. JavaScript renders the client-side template
5. JavaScript injects the template HTML into the
DOM
Today
1. HTML that defines your page and client-side
templates together
2. Get necessary data by AJAX
What is Data Binding
Connect the UI and business
logic of a web application
● New markup
-> Directives: ng-bind, ng-model
-> Expression {{foo}} syntax
● Controller interact through scope
What is Data Binding
How they made it? Dirty-checking
1. $$watchers are registered by directives, expression or $watch
2. $scope.$apply
3. $digest is the cycle that performs dirty checking
a. loop through $$watchers
b. fire any listener event if the watchExp does not equal the last known value
4. $digest runs till no changes detected.
PROS +
● Dirty-checking work on all browsers and
trustable
● Client side templates are cohesive with
your page
● No need manipulation of the DOM
● You have control over the scope of your
JavaScript
● Clean code
● Fast at rendering elements
CONS -
Dirty-checking is slow
Heavy parsing work, or extensive
manipulation and processing
Same binding directive more than once – can
break the data binding process
No built-in computed properties
50ms
Slow — Anything faster than
50 ms is imperceptible to
humans and thus can be
considered as "instant".
POJO
All objects in AngularJS are
POJOs, which stands for
PLAIN OLD JAVA(SCRIPT)
OBJECTS.
10 times
If $digest loops more
than 10 times, app dies
2000
pieces
Limited — You can't really
show more than about 2000
pieces of information to a
human on a single page
10000
watchers
In modern browsers,
AngularJS just take under 6ms
to work on them
Demo
One-Time Binding
One-Time Binding IS NOT One-Way Binding
Allows for a model or view to be updated ONCE from the value set by the controller upon the first
digest cycle
Create only one watch for the expression
Digest loops faster, frees up resources once the binding is stabilized
How it works?
1. First $digest loop meet :: expression A, store value as V
a. If V is not undefined, mark A as deregistered watch
b. If V is undefined, A is still in watch list
1. Continue loop as normal
1. When loop finish, check all deregistered watches
a. If "value" of all deregistered watches are not undefined, remove them from watch list
b. If not, special deregistered watch is still in watch list then loop again
One-Time vs One-Way Binding
One-Way
One time merge
Not automatically
After merge, view and model can be updated
manually
$$watchers remains
One-Time
It's not mean run ONCE
View is updated automatically once
Model can change but view can't
Reduce $$watchers by 1
What else?
Reduce watch count
Avoid ng-repeat where possible
Avoid using $watch where possible
Limit DOM filters
Don't make life complicate
Extra Story
Angular 1.5x provide truly one-way binding
Two-way binding has been dropped from Angular 2 ?
React's one-way data flow (also called one-way binding)
There is no convention for specifying one way or two way bindings
New technologies like AngularJS will show up in ES7+
Q&A

More Related Content

What's hot

Angular Advanced Routing
Angular Advanced RoutingAngular Advanced Routing
Angular Advanced RoutingLaurent Duveau
 
Angular directives and pipes
Angular directives and pipesAngular directives and pipes
Angular directives and pipesKnoldus Inc.
 
AngularJS - Services
AngularJS - ServicesAngularJS - Services
AngularJS - ServicesNir Kaufman
 
Angular - Chapter 3 - Components
Angular - Chapter 3 - ComponentsAngular - Chapter 3 - Components
Angular - Chapter 3 - ComponentsWebStackAcademy
 
Angular 8
Angular 8 Angular 8
Angular 8 Sunil OS
 
Introduction to angular with a simple but complete project
Introduction to angular with a simple but complete projectIntroduction to angular with a simple but complete project
Introduction to angular with a simple but complete projectJadson Santos
 
Angular data binding
Angular data binding Angular data binding
Angular data binding Sultan Ahmed
 
Angular - Chapter 5 - Directives
 Angular - Chapter 5 - Directives Angular - Chapter 5 - Directives
Angular - Chapter 5 - DirectivesWebStackAcademy
 
Angular Pipes Workshop
Angular Pipes WorkshopAngular Pipes Workshop
Angular Pipes WorkshopNir Kaufman
 
Angular 2.0 Dependency injection
Angular 2.0 Dependency injectionAngular 2.0 Dependency injection
Angular 2.0 Dependency injectionEyal Vardi
 
Angular - Chapter 4 - Data and Event Handling
 Angular - Chapter 4 - Data and Event Handling Angular - Chapter 4 - Data and Event Handling
Angular - Chapter 4 - Data and Event HandlingWebStackAcademy
 
Angular App Presentation
Angular App PresentationAngular App Presentation
Angular App PresentationElizabeth Long
 
Angular - Chapter 1 - Introduction
 Angular - Chapter 1 - Introduction Angular - Chapter 1 - Introduction
Angular - Chapter 1 - IntroductionWebStackAcademy
 
Angular 2.0 forms
Angular 2.0 formsAngular 2.0 forms
Angular 2.0 formsEyal Vardi
 
Unit 1 - TypeScript & Introduction to Angular CLI.pptx
Unit 1 - TypeScript & Introduction to Angular CLI.pptxUnit 1 - TypeScript & Introduction to Angular CLI.pptx
Unit 1 - TypeScript & Introduction to Angular CLI.pptxMalla Reddy University
 
Angular 16 – the rise of Signals
Angular 16 – the rise of SignalsAngular 16 – the rise of Signals
Angular 16 – the rise of SignalsCoding Academy
 

What's hot (20)

Angular Advanced Routing
Angular Advanced RoutingAngular Advanced Routing
Angular Advanced Routing
 
Angular directives and pipes
Angular directives and pipesAngular directives and pipes
Angular directives and pipes
 
Angular 9
Angular 9 Angular 9
Angular 9
 
AngularJS - Services
AngularJS - ServicesAngularJS - Services
AngularJS - Services
 
Angular - Chapter 3 - Components
Angular - Chapter 3 - ComponentsAngular - Chapter 3 - Components
Angular - Chapter 3 - Components
 
Angular 8
Angular 8 Angular 8
Angular 8
 
Introduction to angular with a simple but complete project
Introduction to angular with a simple but complete projectIntroduction to angular with a simple but complete project
Introduction to angular with a simple but complete project
 
Angular data binding
Angular data binding Angular data binding
Angular data binding
 
Angular 14.pptx
Angular 14.pptxAngular 14.pptx
Angular 14.pptx
 
Angular - Chapter 5 - Directives
 Angular - Chapter 5 - Directives Angular - Chapter 5 - Directives
Angular - Chapter 5 - Directives
 
Angular Pipes Workshop
Angular Pipes WorkshopAngular Pipes Workshop
Angular Pipes Workshop
 
Angular modules in depth
Angular modules in depthAngular modules in depth
Angular modules in depth
 
Angular 2.0 Dependency injection
Angular 2.0 Dependency injectionAngular 2.0 Dependency injection
Angular 2.0 Dependency injection
 
Angular - Chapter 4 - Data and Event Handling
 Angular - Chapter 4 - Data and Event Handling Angular - Chapter 4 - Data and Event Handling
Angular - Chapter 4 - Data and Event Handling
 
Angular App Presentation
Angular App PresentationAngular App Presentation
Angular App Presentation
 
Angular - Chapter 1 - Introduction
 Angular - Chapter 1 - Introduction Angular - Chapter 1 - Introduction
Angular - Chapter 1 - Introduction
 
Angular js PPT
Angular js PPTAngular js PPT
Angular js PPT
 
Angular 2.0 forms
Angular 2.0 formsAngular 2.0 forms
Angular 2.0 forms
 
Unit 1 - TypeScript & Introduction to Angular CLI.pptx
Unit 1 - TypeScript & Introduction to Angular CLI.pptxUnit 1 - TypeScript & Introduction to Angular CLI.pptx
Unit 1 - TypeScript & Introduction to Angular CLI.pptx
 
Angular 16 – the rise of Signals
Angular 16 – the rise of SignalsAngular 16 – the rise of Signals
Angular 16 – the rise of Signals
 

Viewers also liked

Brasilia 11-de-maio-de-2016 (1)
Brasilia 11-de-maio-de-2016 (1)Brasilia 11-de-maio-de-2016 (1)
Brasilia 11-de-maio-de-2016 (1)Sergio Pereira
 
Agenda e ficha concurso 2016
Agenda  e ficha   concurso 2016Agenda  e ficha   concurso 2016
Agenda e ficha concurso 2016Sergio Pereira
 
createcompletioncertificate 3
createcompletioncertificate 3createcompletioncertificate 3
createcompletioncertificate 3Malvina Sandidge
 
Arquitectura del software
Arquitectura del softwareArquitectura del software
Arquitectura del softwareSabiH3rr3ra
 
Hanna The Girl That Eluded All Convention In Sing.Com
Hanna  The Girl That Eluded All Convention   In Sing.ComHanna  The Girl That Eluded All Convention   In Sing.Com
Hanna The Girl That Eluded All Convention In Sing.ComDexian Wang
 
Niitiin teewer
Niitiin teewerNiitiin teewer
Niitiin teewerBuka King
 
Fhhhfdghdfhdfzdzhhhkjljjljljjjlljljlljjllljl
FhhhfdghdfhdfzdzhhhkjljjljljjjlljljlljjllljlFhhhfdghdfhdfzdzhhhkjljjljljjjlljljlljjllljl
Fhhhfdghdfhdfzdzhhhkjljjljljjjlljljlljjllljljosemiguel123456
 
Awareness and identity tools for pro-environmental behaviour change
Awareness and identity tools for pro-environmental behaviour changeAwareness and identity tools for pro-environmental behaviour change
Awareness and identity tools for pro-environmental behaviour changeSam Cunningham
 
παρουσίαση δάσος
παρουσίαση   δάσοςπαρουσίαση   δάσος
παρουσίαση δάσοςvagts
 
Estilos de Aprendizagem Honey-Alonso
Estilos de Aprendizagem Honey-AlonsoEstilos de Aprendizagem Honey-Alonso
Estilos de Aprendizagem Honey-AlonsoAlexandra Czepula
 
Avulsion of permanent teeth
Avulsion of permanent teethAvulsion of permanent teeth
Avulsion of permanent teethRasha Adel
 
How-To PowerPoint for Elem.
How-To PowerPoint for Elem.How-To PowerPoint for Elem.
How-To PowerPoint for Elem.iSURF
 

Viewers also liked (15)

Brasilia 11-de-maio-de-2016 (1)
Brasilia 11-de-maio-de-2016 (1)Brasilia 11-de-maio-de-2016 (1)
Brasilia 11-de-maio-de-2016 (1)
 
Agenda e ficha concurso 2016
Agenda  e ficha   concurso 2016Agenda  e ficha   concurso 2016
Agenda e ficha concurso 2016
 
createcompletioncertificate 3
createcompletioncertificate 3createcompletioncertificate 3
createcompletioncertificate 3
 
Arquitectura del software
Arquitectura del softwareArquitectura del software
Arquitectura del software
 
El renacer del asombro
El renacer del asombro El renacer del asombro
El renacer del asombro
 
Hanna The Girl That Eluded All Convention In Sing.Com
Hanna  The Girl That Eluded All Convention   In Sing.ComHanna  The Girl That Eluded All Convention   In Sing.Com
Hanna The Girl That Eluded All Convention In Sing.Com
 
Qp1
Qp1Qp1
Qp1
 
Conceptual de ruedas
Conceptual de ruedasConceptual de ruedas
Conceptual de ruedas
 
Niitiin teewer
Niitiin teewerNiitiin teewer
Niitiin teewer
 
Fhhhfdghdfhdfzdzhhhkjljjljljjjlljljlljjllljl
FhhhfdghdfhdfzdzhhhkjljjljljjjlljljlljjllljlFhhhfdghdfhdfzdzhhhkjljjljljjjlljljlljjllljl
Fhhhfdghdfhdfzdzhhhkjljjljljjjlljljlljjllljl
 
Awareness and identity tools for pro-environmental behaviour change
Awareness and identity tools for pro-environmental behaviour changeAwareness and identity tools for pro-environmental behaviour change
Awareness and identity tools for pro-environmental behaviour change
 
παρουσίαση δάσος
παρουσίαση   δάσοςπαρουσίαση   δάσος
παρουσίαση δάσος
 
Estilos de Aprendizagem Honey-Alonso
Estilos de Aprendizagem Honey-AlonsoEstilos de Aprendizagem Honey-Alonso
Estilos de Aprendizagem Honey-Alonso
 
Avulsion of permanent teeth
Avulsion of permanent teethAvulsion of permanent teeth
Avulsion of permanent teeth
 
How-To PowerPoint for Elem.
How-To PowerPoint for Elem.How-To PowerPoint for Elem.
How-To PowerPoint for Elem.
 

Similar to Understand Data Binding in AngularJS

AngularJS Introduction (Talk given on Aug 5 2013)
AngularJS Introduction (Talk given on Aug 5 2013)AngularJS Introduction (Talk given on Aug 5 2013)
AngularJS Introduction (Talk given on Aug 5 2013)Abhishek Anand
 
Intoduction to Angularjs
Intoduction to AngularjsIntoduction to Angularjs
Intoduction to AngularjsGaurav Agrawal
 
AngularJs presentation
AngularJs presentation AngularJs presentation
AngularJs presentation Phan Tuan
 
A Big Picture Of AngularJS
A Big Picture Of AngularJSA Big Picture Of AngularJS
A Big Picture Of AngularJSNitin Pandit
 
Advanced Tips & Tricks for using Angular JS
Advanced Tips & Tricks for using Angular JSAdvanced Tips & Tricks for using Angular JS
Advanced Tips & Tricks for using Angular JSSimon Guest
 
Angularjs 131211063348-phpapp01
Angularjs 131211063348-phpapp01Angularjs 131211063348-phpapp01
Angularjs 131211063348-phpapp01Arunangsu Sahu
 
Getting Started With AngularJS
Getting Started With AngularJSGetting Started With AngularJS
Getting Started With AngularJSEdureka!
 
Getting Started with AngularJS
Getting Started with AngularJSGetting Started with AngularJS
Getting Started with AngularJSEdureka!
 
An introduction to AngularJS
An introduction to AngularJSAn introduction to AngularJS
An introduction to AngularJSYogesh singh
 
Real World Single Page App - A Knockout Case Study
Real World Single Page App - A Knockout Case StudyReal World Single Page App - A Knockout Case Study
Real World Single Page App - A Knockout Case Studyhousecor
 
AngularJS for Beginners
AngularJS for BeginnersAngularJS for Beginners
AngularJS for BeginnersEdureka!
 
AngularJS Basics
AngularJS BasicsAngularJS Basics
AngularJS BasicsRavi Mone
 
One Weekend With AngularJS
One Weekend With AngularJSOne Weekend With AngularJS
One Weekend With AngularJSYashobanta Bai
 
Dive into Angular, part 3: Performance
Dive into Angular, part 3: PerformanceDive into Angular, part 3: Performance
Dive into Angular, part 3: PerformanceOleksii Prohonnyi
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJSShyjal Raazi
 
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)Binary Studio
 

Similar to Understand Data Binding in AngularJS (20)

AngularJS Introduction (Talk given on Aug 5 2013)
AngularJS Introduction (Talk given on Aug 5 2013)AngularJS Introduction (Talk given on Aug 5 2013)
AngularJS Introduction (Talk given on Aug 5 2013)
 
Intoduction to Angularjs
Intoduction to AngularjsIntoduction to Angularjs
Intoduction to Angularjs
 
Angularjs Basics
Angularjs BasicsAngularjs Basics
Angularjs Basics
 
AngularJs presentation
AngularJs presentation AngularJs presentation
AngularJs presentation
 
A Big Picture Of AngularJS
A Big Picture Of AngularJSA Big Picture Of AngularJS
A Big Picture Of AngularJS
 
Angular js
Angular jsAngular js
Angular js
 
Advanced Tips & Tricks for using Angular JS
Advanced Tips & Tricks for using Angular JSAdvanced Tips & Tricks for using Angular JS
Advanced Tips & Tricks for using Angular JS
 
AngularJs
AngularJsAngularJs
AngularJs
 
Angularjs 131211063348-phpapp01
Angularjs 131211063348-phpapp01Angularjs 131211063348-phpapp01
Angularjs 131211063348-phpapp01
 
Getting Started With AngularJS
Getting Started With AngularJSGetting Started With AngularJS
Getting Started With AngularJS
 
Getting Started with AngularJS
Getting Started with AngularJSGetting Started with AngularJS
Getting Started with AngularJS
 
An introduction to AngularJS
An introduction to AngularJSAn introduction to AngularJS
An introduction to AngularJS
 
Training On Angular Js
Training On Angular JsTraining On Angular Js
Training On Angular Js
 
Real World Single Page App - A Knockout Case Study
Real World Single Page App - A Knockout Case StudyReal World Single Page App - A Knockout Case Study
Real World Single Page App - A Knockout Case Study
 
AngularJS for Beginners
AngularJS for BeginnersAngularJS for Beginners
AngularJS for Beginners
 
AngularJS Basics
AngularJS BasicsAngularJS Basics
AngularJS Basics
 
One Weekend With AngularJS
One Weekend With AngularJSOne Weekend With AngularJS
One Weekend With AngularJS
 
Dive into Angular, part 3: Performance
Dive into Angular, part 3: PerformanceDive into Angular, part 3: Performance
Dive into Angular, part 3: Performance
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
 
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)
 

Recently uploaded

Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 

Recently uploaded (20)

Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 

Understand Data Binding in AngularJS

  • 2. Points What is Data Binding Two-Way vs One-Time Binding Demos & QA
  • 3. Background Tool Age DOM manipulation tool like JQuery Bronze Age Client-side templating tool like Mustache, Handlebars.js Iron Age Angular, React
  • 4. How we develop a web app Before 1. HTML that defines your page 2. Get necessary data by AJAX 3. Client side templating (Script hack: <script type="text/html">...</script>) 4. JavaScript renders the client-side template 5. JavaScript injects the template HTML into the DOM Today 1. HTML that defines your page and client-side templates together 2. Get necessary data by AJAX
  • 5. What is Data Binding Connect the UI and business logic of a web application ● New markup -> Directives: ng-bind, ng-model -> Expression {{foo}} syntax ● Controller interact through scope
  • 6. What is Data Binding
  • 7. How they made it? Dirty-checking 1. $$watchers are registered by directives, expression or $watch 2. $scope.$apply 3. $digest is the cycle that performs dirty checking a. loop through $$watchers b. fire any listener event if the watchExp does not equal the last known value 4. $digest runs till no changes detected.
  • 8. PROS + ● Dirty-checking work on all browsers and trustable ● Client side templates are cohesive with your page ● No need manipulation of the DOM ● You have control over the scope of your JavaScript ● Clean code ● Fast at rendering elements CONS - Dirty-checking is slow Heavy parsing work, or extensive manipulation and processing Same binding directive more than once – can break the data binding process No built-in computed properties
  • 9. 50ms Slow — Anything faster than 50 ms is imperceptible to humans and thus can be considered as "instant". POJO All objects in AngularJS are POJOs, which stands for PLAIN OLD JAVA(SCRIPT) OBJECTS. 10 times If $digest loops more than 10 times, app dies 2000 pieces Limited — You can't really show more than about 2000 pieces of information to a human on a single page 10000 watchers In modern browsers, AngularJS just take under 6ms to work on them
  • 10. Demo
  • 11. One-Time Binding One-Time Binding IS NOT One-Way Binding Allows for a model or view to be updated ONCE from the value set by the controller upon the first digest cycle Create only one watch for the expression Digest loops faster, frees up resources once the binding is stabilized
  • 12. How it works? 1. First $digest loop meet :: expression A, store value as V a. If V is not undefined, mark A as deregistered watch b. If V is undefined, A is still in watch list 1. Continue loop as normal 1. When loop finish, check all deregistered watches a. If "value" of all deregistered watches are not undefined, remove them from watch list b. If not, special deregistered watch is still in watch list then loop again
  • 13. One-Time vs One-Way Binding One-Way One time merge Not automatically After merge, view and model can be updated manually $$watchers remains One-Time It's not mean run ONCE View is updated automatically once Model can change but view can't Reduce $$watchers by 1
  • 14. What else? Reduce watch count Avoid ng-repeat where possible Avoid using $watch where possible Limit DOM filters Don't make life complicate
  • 15. Extra Story Angular 1.5x provide truly one-way binding Two-way binding has been dropped from Angular 2 ? React's one-way data flow (also called one-way binding) There is no convention for specifying one way or two way bindings New technologies like AngularJS will show up in ES7+
  • 16. Q&A