SlideShare a Scribd company logo
1
Comparing React and
Angular
Discussion Agenda
• React and Angular Tool Overview
• Side-By-Side Comparison
• Sample Code
• Architectural Comparisons:
• Component Tree Architecture
• Angular Digest Cycle
• React Virtual DOM
• Data Binding
• Big Picture Comparison
2
Overview
3
Angular is a Framework for
building Web Applications.
React is a JavaScript Library
for building User Interfaces.
Overview
4
Different problems are often best solved using different
tools. We will be discussing the features of React and
Angular and how they are both best suited for building
different types of Single Page Applications.
Overview – Developer Interest
5
Interestingly, in the 2017 Stack Overflow survey, React is
the most loved technology, while AngularJS is the most
used web development technology.
In general, developers tend to enjoy working with React
very much, while architectural decisions tend to be made
favoring Angular.
https://insights.stackoverflow.com/survey/2017#technology
Overview - Angular
6
• TypeScript-based open-source front-end web
application platform for building single page
applications.
• Uses component based architecture.
• Creates components by grouping structure and
function into HTML templates.
• Developers use components to build apps
declaratively.
• Provides simple framework solutions for
foundational functionality (routing, HTTP, forms,
etc) which can be customized.
• Digest cycle re-renders entire view when
data is updated.
• Functionality is organized into modules which
are loaded dynamically.
• Angular apps are loosely MVC, MVW, etc.
• Angular apps need to be built
Overview – React
7
• JavaScript library for building user interfaces.
• Uses components to build UIs.
• React components manage their own internal
state
• Components are written in JavaScript and JSX
• Only contains library functions for building views
• Builds views from encapsulated components
so UI only updates necessary elements when
data changes.
• All components contain structure by
implementing render() function which returns
HTML.
• React library is light, and needs outside tools to
serve, reuse components, etc.
• Standard tools exist, however (ex. create-react-
app
• React Uis also need to be built.
Side-By-Side Comparison of Angular and React - Stats
8
Side-By-Side Comparison of Angular and React - Features
9
Sample Code
<form (ngSubmit)="onSubmit(heroForm)"
#heroForm="ngForm">
<div class="form-group">
<label for="name">Name
<input class="form-control" name="name"
required [(ngModel)]="hero.name">
</label>
</div>
<button type="submit"
[disabled]="!heroForm.form.valid">Submit</b
utton>
</form>
<div [hidden]="!heroForm.form.valid">
{{submitMessage}}
</div>
10
var Saves = React.createClass({
getInitialState: function(){
…..
},
handleSubmit: function(e) {
…
},
render: function() {
var savedText = '';
var submitText = 'Save';
if (this.state.saved) {
savedText = 'You have saved this home.';
submitText = 'Remove';
}
return (
<div className="saves">
<form onSubmit={this.handleSubmit}>
<input type="submit" value={submitText} />
</form>
{this.state.numSaves} saves. {savedText}
</div>
);
}
});
JavaScript in HTML!
JS Render function
contains HTML!
Angular Template React JS Class
Review: Component Based Architecture
• Components are UI elements
which encapsulate functionality
and structure.
• Components are custom HTML
elements which contain HTML
coupled with functionality defined
in JavaScript.
• Components also contain an
isolated data scope. React
components use their isolated
scope to independently update the
view when bound data changes.
• The DOM is a tree of
components. There is a root
component and child components
as in the basic DOM.
11
How Angular Renders Components
• Angular components exist in TypeScript Component files and their corresponding
HTML template files.
• Angular renders a view by loading the base component (defined in the base module)
in TypeScript code and rendering the resulting tree of components.
• When Angular renders a component, it loads the component TypeScript code into
memory, then renders the resulting augmented HTML into the browser by parsing
the HTML template file and adding functionality (events, bound data, etc) from the
component code.
• When data bound to the view changes, the framework Digest Cycle is triggered to
refresh the rendered view.
• The Digest Cycle checks all databindings and updates any necessary values in the
augmented HTML, then re-renders the entire HTML DOM tree to refresh the page.
12
+ =
How React Renders Components
• React components exist in JS files which contain HTML embedded into JSX.
• A React view is built from independent components with isolated states.
• The base ReactDOM.Render() JavaScript method renders the view by calling the render()
method on each element in the DOM tree. Render() returns HTML.
• Conceptually, components are like JavaScript functions. They accept arbitrary inputs (called
“props”) and return React elements describing what should appear on the screen.
• The view consists of independent components which are only updated when the individual
state changes.
• When data bound to a React element changes, the render() method is triggered on the
element and it is updated in isolation.
13
Every React component
has a Render() method
React Virtual DOM
• React handles the DOM
considerably more efficient than
Angular’s Digest Cycle does.
• React keeps a copy of the DOM in
memory, called the Virtual DOM.
• When data on any component
changes, React updates the Virtual
DOM node associated with the
updated data.
• After updating the Virtual DOM,
React diffs it with the actual DOM.
• React uses the results of the diff to
re-render any updated component
on the actual DOM.
14
Angular Digest Cycle
15
• The Digest Cycle is the process by which Angular updates the view
after model data has been updated.
• The Angular framework registers a watch on all data bound
elements.
• When a data bound element changes, (or the digest cycle is
manually triggered in code), the framework evaluates every data
bound element to check if the value has changed.
• The framework re-renders the entire DOM with the updated data.
Data Binding
16
• Angular uses 2 – Way Data Binding, where any updates on the UI
are bound to the model automatically, and any model updates
(service, async communication, etc) are immediately visible to the
UI. Updating any piece of data triggers the Digest Cycle.
• React uses 1 – Way Data Binding, where updates to the UI trigger
events which call functions on the data model that update the data
and state. Remember that components have individual data
models.
Disclaimer: Angular has
optimized the Digest Cycle to
work more efficiently, but I
will leave the details for a
further discussion
Big Picture Comparison
• Angular’s Digest Cycle updates the entire
view when any data bound to a UI element is
updated.
• Angular is a framework, so it contains a lot of
useful of out-of-the box functionality that React
would require customization to implement.
• Angular is versioned and the standard
implementation is well documented by Google.
• Angular has a difficult learning curve, and in
general is harder to debug than React.
• The Angular CLI makes setup and development
very easy, however.
17
• React diffs DOM updates using a copy of the
DOM in memory and only updates relevant
view components when data is updated.
• The React landscape is quite mature,
however, and it is easy to find tools to help
streamline development. As a result, React
apps are typically coupled with other JS
libraries.
• There is no standard React project
configuration, and only a set of best practices
(Redux, Flux, ect)
• In my experience, React is easier to debug
because the render() method is exposed in
source code.
• Use the create-react-app tool to do (almost)
as much as the Angular CLI
Another Comparison Table

More Related Content

What's hot (20)

PPTX
React js Online Training
Learntek1
 
PPTX
React js for beginners
Alessandro Valenti
 
PPTX
Reactjs
Neha Sharma
 
PDF
React Js Simplified
Sunil Yadav
 
PPTX
Intro to React
Eric Westfall
 
PPTX
Angular View Encapsulation
Jennifer Estrada
 
PPTX
React JS - A quick introduction tutorial
Mohammed Fazuluddin
 
PPTX
Introduction to React JS
Lohith Goudagere Nagaraj
 
PPTX
React render props
Saikat Samanta
 
PPTX
Introduction to react js
Aeshan Wijetunge
 
PPTX
Introduction to ReactJs & fundamentals
websyndicate
 
PPTX
React js
Nikhil Karkra
 
PPTX
[Final] ReactJS presentation
洪 鹏发
 
PPTX
ReactJs
Sahana Banerjee
 
PDF
Introduction to React JS
Bethmi Gunasekara
 
PPTX
Its time to React.js
Ritesh Mehrotra
 
PPSX
React introduction
Kashyap Parmar
 
PDF
Introduction to Spring MVC
Richard Paul
 
PPTX
Introduction to React
Rob Quick
 
PDF
React.js
Łukasz Kużyński
 
React js Online Training
Learntek1
 
React js for beginners
Alessandro Valenti
 
Reactjs
Neha Sharma
 
React Js Simplified
Sunil Yadav
 
Intro to React
Eric Westfall
 
Angular View Encapsulation
Jennifer Estrada
 
React JS - A quick introduction tutorial
Mohammed Fazuluddin
 
Introduction to React JS
Lohith Goudagere Nagaraj
 
React render props
Saikat Samanta
 
Introduction to react js
Aeshan Wijetunge
 
Introduction to ReactJs & fundamentals
websyndicate
 
React js
Nikhil Karkra
 
[Final] ReactJS presentation
洪 鹏发
 
Introduction to React JS
Bethmi Gunasekara
 
Its time to React.js
Ritesh Mehrotra
 
React introduction
Kashyap Parmar
 
Introduction to Spring MVC
Richard Paul
 
Introduction to React
Rob Quick
 

Similar to Comparing Angular and React JS for SPAs (20)

PDF
Angular vs.pdf
SophiaJasper
 
PDF
React vs. angular a comprehensive guideline for choosing right front-end fr...
Katy Slemon
 
PPTX
Combining Angular and React Together
Sebastian Pederiva
 
PDF
Getting Started with React, When You’re an Angular Developer
Fabrit Global
 
PDF
Angular vs react comparison in 2022 which is better and why
Noman Shaikh
 
PDF
AngularJS Vs ReactJS_ What’s The Difference_.pdf
Onviqa Pvt. Ltd.
 
PPTX
Angular vs react
Infinijith Technologies
 
PDF
Which technology has a better future_ AngularJS or ReactJS_.pdf
Moon Technolabs Pvt. Ltd.
 
PDF
React.js vs angular.js a comparison
Narola Infotech
 
PDF
React vs angular which front end framework should you choose and why
Katy Slemon
 
PPTX
React vs angular what to choose for your app
Concetto Labs
 
PDF
Angular vs React: Making an Informed Decision for Your Web Development
FredReynolds2
 
PDF
Comparison Between React Vs Angular.pdf
StephieJohn
 
PDF
React js vs angularjs which framework to choose in 2022_
Moon Technolabs Pvt. Ltd.
 
PPTX
Angular vs React: Pick the Right Front-End in 2024
Consumer Sketch
 
PDF
Angular vs React 2019 [UPDATED] - tecHindustan
tecHIndustan Solutions
 
PPTX
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)
Binary Studio
 
DOCX
React VS Angular- Which is Best for You in 2023?
CMARIX TechnoLabs
 
PDF
AngularJS vs ReactJS: Which One is Best for Next Front-end Development
Andolasoft Inc
 
PDF
React vs Angular - Which is best JS Framework for Front-end Development
Pixlogix Infotech
 
Angular vs.pdf
SophiaJasper
 
React vs. angular a comprehensive guideline for choosing right front-end fr...
Katy Slemon
 
Combining Angular and React Together
Sebastian Pederiva
 
Getting Started with React, When You’re an Angular Developer
Fabrit Global
 
Angular vs react comparison in 2022 which is better and why
Noman Shaikh
 
AngularJS Vs ReactJS_ What’s The Difference_.pdf
Onviqa Pvt. Ltd.
 
Angular vs react
Infinijith Technologies
 
Which technology has a better future_ AngularJS or ReactJS_.pdf
Moon Technolabs Pvt. Ltd.
 
React.js vs angular.js a comparison
Narola Infotech
 
React vs angular which front end framework should you choose and why
Katy Slemon
 
React vs angular what to choose for your app
Concetto Labs
 
Angular vs React: Making an Informed Decision for Your Web Development
FredReynolds2
 
Comparison Between React Vs Angular.pdf
StephieJohn
 
React js vs angularjs which framework to choose in 2022_
Moon Technolabs Pvt. Ltd.
 
Angular vs React: Pick the Right Front-End in 2024
Consumer Sketch
 
Angular vs React 2019 [UPDATED] - tecHindustan
tecHIndustan Solutions
 
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)
Binary Studio
 
React VS Angular- Which is Best for You in 2023?
CMARIX TechnoLabs
 
AngularJS vs ReactJS: Which One is Best for Next Front-end Development
Andolasoft Inc
 
React vs Angular - Which is best JS Framework for Front-end Development
Pixlogix Infotech
 
Ad

Recently uploaded (20)

PDF
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
PDF
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
PPTX
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
PPTX
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
PDF
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
PDF
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
PDF
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
PPTX
Transforming Mining & Engineering Operations with Odoo ERP | Streamline Proje...
SatishKumar2651
 
PPTX
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PDF
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
PPTX
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
PDF
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
PDF
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
PDF
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
PDF
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
PPTX
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
PDF
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
PDF
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
PPTX
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
Transforming Mining & Engineering Operations with Odoo ERP | Streamline Proje...
SatishKumar2651
 
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
Ad

Comparing Angular and React JS for SPAs

  • 2. Discussion Agenda • React and Angular Tool Overview • Side-By-Side Comparison • Sample Code • Architectural Comparisons: • Component Tree Architecture • Angular Digest Cycle • React Virtual DOM • Data Binding • Big Picture Comparison 2
  • 3. Overview 3 Angular is a Framework for building Web Applications. React is a JavaScript Library for building User Interfaces.
  • 4. Overview 4 Different problems are often best solved using different tools. We will be discussing the features of React and Angular and how they are both best suited for building different types of Single Page Applications.
  • 5. Overview – Developer Interest 5 Interestingly, in the 2017 Stack Overflow survey, React is the most loved technology, while AngularJS is the most used web development technology. In general, developers tend to enjoy working with React very much, while architectural decisions tend to be made favoring Angular. https://insights.stackoverflow.com/survey/2017#technology
  • 6. Overview - Angular 6 • TypeScript-based open-source front-end web application platform for building single page applications. • Uses component based architecture. • Creates components by grouping structure and function into HTML templates. • Developers use components to build apps declaratively. • Provides simple framework solutions for foundational functionality (routing, HTTP, forms, etc) which can be customized. • Digest cycle re-renders entire view when data is updated. • Functionality is organized into modules which are loaded dynamically. • Angular apps are loosely MVC, MVW, etc. • Angular apps need to be built
  • 7. Overview – React 7 • JavaScript library for building user interfaces. • Uses components to build UIs. • React components manage their own internal state • Components are written in JavaScript and JSX • Only contains library functions for building views • Builds views from encapsulated components so UI only updates necessary elements when data changes. • All components contain structure by implementing render() function which returns HTML. • React library is light, and needs outside tools to serve, reuse components, etc. • Standard tools exist, however (ex. create-react- app • React Uis also need to be built.
  • 8. Side-By-Side Comparison of Angular and React - Stats 8
  • 9. Side-By-Side Comparison of Angular and React - Features 9
  • 10. Sample Code <form (ngSubmit)="onSubmit(heroForm)" #heroForm="ngForm"> <div class="form-group"> <label for="name">Name <input class="form-control" name="name" required [(ngModel)]="hero.name"> </label> </div> <button type="submit" [disabled]="!heroForm.form.valid">Submit</b utton> </form> <div [hidden]="!heroForm.form.valid"> {{submitMessage}} </div> 10 var Saves = React.createClass({ getInitialState: function(){ ….. }, handleSubmit: function(e) { … }, render: function() { var savedText = ''; var submitText = 'Save'; if (this.state.saved) { savedText = 'You have saved this home.'; submitText = 'Remove'; } return ( <div className="saves"> <form onSubmit={this.handleSubmit}> <input type="submit" value={submitText} /> </form> {this.state.numSaves} saves. {savedText} </div> ); } }); JavaScript in HTML! JS Render function contains HTML! Angular Template React JS Class
  • 11. Review: Component Based Architecture • Components are UI elements which encapsulate functionality and structure. • Components are custom HTML elements which contain HTML coupled with functionality defined in JavaScript. • Components also contain an isolated data scope. React components use their isolated scope to independently update the view when bound data changes. • The DOM is a tree of components. There is a root component and child components as in the basic DOM. 11
  • 12. How Angular Renders Components • Angular components exist in TypeScript Component files and their corresponding HTML template files. • Angular renders a view by loading the base component (defined in the base module) in TypeScript code and rendering the resulting tree of components. • When Angular renders a component, it loads the component TypeScript code into memory, then renders the resulting augmented HTML into the browser by parsing the HTML template file and adding functionality (events, bound data, etc) from the component code. • When data bound to the view changes, the framework Digest Cycle is triggered to refresh the rendered view. • The Digest Cycle checks all databindings and updates any necessary values in the augmented HTML, then re-renders the entire HTML DOM tree to refresh the page. 12 + =
  • 13. How React Renders Components • React components exist in JS files which contain HTML embedded into JSX. • A React view is built from independent components with isolated states. • The base ReactDOM.Render() JavaScript method renders the view by calling the render() method on each element in the DOM tree. Render() returns HTML. • Conceptually, components are like JavaScript functions. They accept arbitrary inputs (called “props”) and return React elements describing what should appear on the screen. • The view consists of independent components which are only updated when the individual state changes. • When data bound to a React element changes, the render() method is triggered on the element and it is updated in isolation. 13 Every React component has a Render() method
  • 14. React Virtual DOM • React handles the DOM considerably more efficient than Angular’s Digest Cycle does. • React keeps a copy of the DOM in memory, called the Virtual DOM. • When data on any component changes, React updates the Virtual DOM node associated with the updated data. • After updating the Virtual DOM, React diffs it with the actual DOM. • React uses the results of the diff to re-render any updated component on the actual DOM. 14
  • 15. Angular Digest Cycle 15 • The Digest Cycle is the process by which Angular updates the view after model data has been updated. • The Angular framework registers a watch on all data bound elements. • When a data bound element changes, (or the digest cycle is manually triggered in code), the framework evaluates every data bound element to check if the value has changed. • The framework re-renders the entire DOM with the updated data.
  • 16. Data Binding 16 • Angular uses 2 – Way Data Binding, where any updates on the UI are bound to the model automatically, and any model updates (service, async communication, etc) are immediately visible to the UI. Updating any piece of data triggers the Digest Cycle. • React uses 1 – Way Data Binding, where updates to the UI trigger events which call functions on the data model that update the data and state. Remember that components have individual data models. Disclaimer: Angular has optimized the Digest Cycle to work more efficiently, but I will leave the details for a further discussion
  • 17. Big Picture Comparison • Angular’s Digest Cycle updates the entire view when any data bound to a UI element is updated. • Angular is a framework, so it contains a lot of useful of out-of-the box functionality that React would require customization to implement. • Angular is versioned and the standard implementation is well documented by Google. • Angular has a difficult learning curve, and in general is harder to debug than React. • The Angular CLI makes setup and development very easy, however. 17 • React diffs DOM updates using a copy of the DOM in memory and only updates relevant view components when data is updated. • The React landscape is quite mature, however, and it is easy to find tools to help streamline development. As a result, React apps are typically coupled with other JS libraries. • There is no standard React project configuration, and only a set of best practices (Redux, Flux, ect) • In my experience, React is easier to debug because the render() method is exposed in source code. • Use the create-react-app tool to do (almost) as much as the Angular CLI