SlideShare a Scribd company logo
Angular or React ?
Which fits your needs?
Speaker
• Orkhan Gasimov, Software Engineer
– 14 years of software engineering;
– variety of technologies (languages & frameworks);
– solution design and implementation;
• Technology consulting and training:
– Architecture.
– Java.
– JavaScript / TypeScript.
• Author of training courses.
– Spring Cloud.
– Akka for Java.
Angular or React?
Angular or React?
Agenda
• Describe the difference of two.
• Analyze an example project.
• Overview core concepts.
• Final decision making.
• Questions & Answers
Google & Facebook
Google – Angular
• Google – many apps with single user id.
• Angular – single framework with many features.
Facebook – React
• Facebook – single portal with many features.
• React – many libraries for single application.
Project
Project
• Imagine an example project with following functionality:
– User logon;
– Home page;
– Settings page;
– Data page;
– Etc.
Project
• High-level project architecture consists of:
– Web GUI;
– REST API Server;
– Database;
Project
Project
• Web page oriented development
Project
• Web page oriented development
– HTML pages loaded from server and rendered in browser.
Project
• Web page oriented development
– HTML pages loaded from server and rendered in browser.
– Navigation through pages.
Project
• Web page oriented development
– HTML pages loaded from server and rendered in browser.
– Navigation through pages.
• Web experience oriented application development
Project
• Web page oriented development
– HTML pages loaded from server and rendered in browser.
– Navigation through pages.
• Web experience oriented application development
– Single page application – a desktop application with web experience.
Project
• Web page oriented development
– HTML pages loaded from server and rendered in browser.
– Navigation through pages.
• Web experience oriented application development
– Single page application – a desktop application with web experience.
– Partial update of necessary regions, windows, panes.
Project
• Web page oriented development
– HTML pages loaded from server and rendered in browser.
– Navigation through pages.
• Web experience oriented application development
– Single page application – a desktop application with web experience.
– Partial update of necessary regions, windows, panes.
– Application loads once, only data is refreshed.
Project
• Web page oriented development
– HTML pages loaded from server and rendered in browser.
– Navigation through pages.
• Web experience oriented application development
– Single page application – a desktop application with web experience.
– Partial update of necessary regions, windows, panes.
– Application loads once, only data is refreshed.
– URLs, back & forward navigation.
Project
• Web page oriented development
– HTML pages loaded from server and rendered in browser.
– Navigation through pages.
• Web experience oriented application development
– Single page application – a desktop application with web experience.
– Partial update of necessary regions, windows, panes.
– Application loads once, only data is refreshed.
– URLs, back & forward navigation.
– Caching, offline mode.
Project
Project
Project
• What is required?
– JS toolkit that enables single page application development.
– Reusable UI components support.
Project
• Building blocks
– Components
Project
• Web page decomposed to components
Project
• Component approach
Project
• Component approach
Project
• Programming languages available?
Project
• Programming languages available?
Language
Angular – Language
• TypeScript
@Component({...})
class MyComponent {
constructor(private http:Http, private router: Router) {
...
}
}
React – Language
• JavaScript (ES5 / ES6)
• TypeScript also supports React
var MyComponent = React.createClass({
render: function() {
...
}
});
class MyComponent extends React.Component {
render() {
...
}
}
Approach
Angular – Approach
• Angular is a framework with dependency injection.
• The UI is component based.
• Application is composed from components, services and other elements.
@Component({...})
class MyComponent {
constructor(private http:Http, private router: Router) {
...
}
}
React – Approach
• React is a library.
• It is about components, and components.
class MyComponent extends React.Component {
render() {
return <div>Component</div>;
}
}
React
• Component
Angular
React
• Component
– Template
• HTML block that should be rendered with this component.
Angular
React
• Component
– Template
• HTML block that should be rendered with this component.
– State
• Private data that component should render or use for calculations.
Angular
React
• Component
– Template
• HTML block that should be rendered with this component.
– State
• Private data that component should render or use for calculations.
– Properties
• Properties that may be passed from outside world to a component.
Angular
React
• Component
– Template
• HTML block that should be rendered with this component.
– State
• Private data that component should render or use for calculations.
– Properties
• Properties that may be passed from outside world to a component.
Angular
Templates
Angular – Templates
• HTML templates with JS code
@Component({
selector: 'my-component',
template: '<div>{{name}}</div>'
})
class MyComponent {
private name = 'Component';
constructor(private http:Http, private router: Router) {
...
}
}
React – Templates
• JSX – JS code with HTML markup
const name = 'Component';
class MyComponent extends React.Component {
render() {
return <div>{name}</div>;
}
}
State
Angular – State
• Component is an instance of a class.
• State of object is the state of component.
@Component({
selector: 'my-component',
template: '<div>{{name}}</div>'
})
class MyComponent {
private name = 'Component';
updateName() {
this.name = "Updated component";
}
constructor(private http:Http, private router: Router) {
...
}
}
React – State
• Custom approach to state handling.
class MyComponent extends React.Component {
constructor() {
this.state = {name: 'Component'};
}
updateName() {
this.setState({name: "Updated component"});
}
render() {
return <div>{this.state.name}</div>;
}
}
Properties
Angular – Properties
• Property syntax with @Input decorator should be used.
<MyComponent [text]="Sample text"/>
@Component({
selector: 'my-component',
template: '<div>{{text}}</div>'
})
class MyComponent {
@Input()
private text = 'Component';
}
React – Properties
• Special props object is available inside the component.
<MyComponent text="Sample text"/>
class MyComponent extends React.Component {
render() {
return <div>{this.props.text}</div>;
}
}
ReactAngular
ReactAngular
Beyond Components
What else?
• Beyond Components
What else?
• Beyond Components
– Events
• Event oriented programming with custom application events.
What else?
• Beyond Components
– Events
• Event oriented programming with custom application events.
– HTTP
• We need somehow receive data from and send data to server.
What else?
• Beyond Components
– Events
• Event oriented programming with custom application events.
– HTTP
• We need somehow receive data from and send data to server.
– Routing
• Navigation over URLs requires different components to be rendered.
Events
Angular – Events
• Framework supports event-oriented development with special constructs.
<MyComponent (myEvent)="eventHandler(event)"/>
@Component({...})
class MyComponent {
@Output()
myEvent: EventEmitter<string> = new EventEmitter<string>();
triggerEvent(event: string) {
this.myEvent.emit(event);
}
}
React – Events
• Library does not support event-driven development out of the box.
• There many third party libraries to use, as well as react adapted ones.
HTTP
Angular – HTTP
• Framework provides HTTP module based on RxJS.
@Component({...})
class MyComponent {
constructor(private http:Http) {
}
getData(): Observable<DataItem[]> {
return this.http.get("http://localhost/data")
.map(response => response.json() as DataItem[]);
};
}
React – HTTP
• Library does not provide HTTP support out of the box.
• Native JS or third party libraries should be used.
class MyComponent extends React.Component {
getData() {
fetch("http://localhost/data")
.then(function (response) {
return response.json()
})
}
}
Routing
Routing
Angular – Routing
• Framework supports routing out of the box.
const appRoutes: Routes = [
{path: 'crisis-center', component: CrisisListComponent},
{path: 'hero/:id', component: HeroDetailComponent},
{path: '**', component: PageNotFoundComponent}
];
@NgModule({
imports: [RouterModule.forRoot(appRoutes)],
...
})
export class AppModule {
}
React – Routing
• Facebook developed react-router as separate library:
• Third party libraries are also available.
render(
<Router history={browserHistory}>
<Route path='/' component={App}>
<IndexRoute component={Home} />
<Route path='admin' component={Admin} />
<Route path='genre' component={Genre} />
</Route>
</Router>,
document.getElementById('root')
)
Summary
Summary
• In scope
Summary
• In scope
– Components
Summary
• In scope
– Components
• Templates
Summary
• In scope
– Components
• Templates
• State
Summary
• In scope
– Components
• Templates
• State
• Properties
Summary
• In scope
– Components
• Templates
• State
• Properties
– Events
Summary
• In scope
– Components
• Templates
• State
• Properties
– Events
– HTTP
Summary
• In scope
– Components
• Templates
• State
• Properties
– Events
– HTTP
– Routing
Summary
• In scope
– Components
• Templates
• State
• Properties
– Events
– HTTP
– Routing
• Out of scope
– Flux
Angular
• Angular – single framework with many features.
– Dependency Injection;
– Components;
– Services;
– Directives;
– Pipes;
– HTTP;
– Router;
– etc.
React
• React – many libraries for single application.
– Components;
– State handling;
– Props handling;
– JSX;
React
• Angular – single framework with many features.
– Dependency Injection, Components, Services,
Directives, Pipes, HTTP, Router and etc.
• React – many libraries for single application.
– Components, state and props handling + JSX.
Angular
Thank you!

More Related Content

What's hot (20)

PDF
Webinar | Better Together: Apache Cassandra and Apache Kafka
DataStax
 
PDF
Event Driven Architectures with Apache Kafka on Heroku
Heroku
 
PDF
Cloudstate - Towards Stateful Serverless
Lightbend
 
PDF
Kafka Needs No Keeper
C4Media
 
PPTX
CQRS & EVS with MongoDb
Lluis Fernandez
 
PDF
Oracle Fuson Middleware Diagnostics, Performance and Troubleshoot
Michel Schildmeijer
 
PDF
Can Apache Kafka Replace a Database? – The 2021 Update | Kai Waehner, Confluent
HostedbyConfluent
 
PDF
Making Kafka Cloud Native | Jay Kreps, Co-Founder & CEO, Confluent
HostedbyConfluent
 
PPTX
Akka for big data developers
Taras Fedorov
 
PPTX
Building an Event Bus at Scale
jimriecken
 
PPTX
System design for video streaming service
Nirmik Kale
 
PPTX
Intro to Apache Kafka
Jason Hubbard
 
PDF
Keynote Oracle Fusion Middleware Summit_2020
Michel Schildmeijer
 
PPTX
Spring Cloud: API gateway upgrade & configuration in the cloud
Orkhan Gasimov
 
PDF
Using Machine Learning to Understand Kafka Runtime Behavior (Shivanath Babu, ...
confluent
 
PPTX
Oracle OpenWorld 2014 Review Part Four - PaaS Middleware
Getting value from IoT, Integration and Data Analytics
 
PPTX
Lightbend Training for Scala, Akka, Play Framework and Apache Spark
Lightbend
 
PPTX
Expect the unexpected: Anticipate and prepare for failures in microservices b...
Bhakti Mehta
 
PDF
The 6 Rules for Modernizing Your Legacy Java Monolith with Microservices
Lightbend
 
PDF
The Java Microservice Library
Rick Hightower
 
Webinar | Better Together: Apache Cassandra and Apache Kafka
DataStax
 
Event Driven Architectures with Apache Kafka on Heroku
Heroku
 
Cloudstate - Towards Stateful Serverless
Lightbend
 
Kafka Needs No Keeper
C4Media
 
CQRS & EVS with MongoDb
Lluis Fernandez
 
Oracle Fuson Middleware Diagnostics, Performance and Troubleshoot
Michel Schildmeijer
 
Can Apache Kafka Replace a Database? – The 2021 Update | Kai Waehner, Confluent
HostedbyConfluent
 
Making Kafka Cloud Native | Jay Kreps, Co-Founder & CEO, Confluent
HostedbyConfluent
 
Akka for big data developers
Taras Fedorov
 
Building an Event Bus at Scale
jimriecken
 
System design for video streaming service
Nirmik Kale
 
Intro to Apache Kafka
Jason Hubbard
 
Keynote Oracle Fusion Middleware Summit_2020
Michel Schildmeijer
 
Spring Cloud: API gateway upgrade & configuration in the cloud
Orkhan Gasimov
 
Using Machine Learning to Understand Kafka Runtime Behavior (Shivanath Babu, ...
confluent
 
Oracle OpenWorld 2014 Review Part Four - PaaS Middleware
Getting value from IoT, Integration and Data Analytics
 
Lightbend Training for Scala, Akka, Play Framework and Apache Spark
Lightbend
 
Expect the unexpected: Anticipate and prepare for failures in microservices b...
Bhakti Mehta
 
The 6 Rules for Modernizing Your Legacy Java Monolith with Microservices
Lightbend
 
The Java Microservice Library
Rick Hightower
 

Similar to Angular or React (20)

PDF
Angular vs.pdf
SophiaJasper
 
PDF
Getting Started with React, When You’re an Angular Developer
Fabrit Global
 
PDF
ReactJS - frontend web developing reactjs
ducpvcontact
 
PPTX
React vs angular what to choose for your app
Concetto Labs
 
PDF
React vs. angular a comprehensive guideline for choosing right front-end fr...
Katy Slemon
 
PDF
React - The JavaScript Library for User Interfaces
Jumping Bean
 
PPTX
Frontend War: Angular vs React vs Vue
Marudi Subakti
 
PDF
Comparison Between React Vs Angular.pdf
StephieJohn
 
PDF
Angular VS React The Battle of Best Front End Frameworks.pdf
JS Panther
 
PPTX
Full Stack_Reac web Development and Application
Jeyarajs7
 
PPTX
Engineering Frontends
Vladimir Milojević
 
PDF
React & Flux Workshop
Christian Lilley
 
PDF
React js vs angularjs which framework to choose in 2022_
Moon Technolabs Pvt. Ltd.
 
PPTX
Comparing Angular and React JS for SPAs
Jennifer Estrada
 
PDF
Comparing AngularJS and ReactJS_ Finding the Best Framework for your Next Pro...
JPLoft Solutions
 
DOCX
React VS Angular- Which is Best for You in 2023?
CMARIX TechnoLabs
 
PPTX
Angular vs React vs Vue
Hosein Mansouri
 
PDF
Angular vs react.pdf
Decoro Software Solutions
 
PPTX
Professionalizing the Front-end
Jordi Anguela
 
PDF
Introduction to javascript technologies
Abdalla Elsayed
 
Angular vs.pdf
SophiaJasper
 
Getting Started with React, When You’re an Angular Developer
Fabrit Global
 
ReactJS - frontend web developing reactjs
ducpvcontact
 
React vs angular what to choose for your app
Concetto Labs
 
React vs. angular a comprehensive guideline for choosing right front-end fr...
Katy Slemon
 
React - The JavaScript Library for User Interfaces
Jumping Bean
 
Frontend War: Angular vs React vs Vue
Marudi Subakti
 
Comparison Between React Vs Angular.pdf
StephieJohn
 
Angular VS React The Battle of Best Front End Frameworks.pdf
JS Panther
 
Full Stack_Reac web Development and Application
Jeyarajs7
 
Engineering Frontends
Vladimir Milojević
 
React & Flux Workshop
Christian Lilley
 
React js vs angularjs which framework to choose in 2022_
Moon Technolabs Pvt. Ltd.
 
Comparing Angular and React JS for SPAs
Jennifer Estrada
 
Comparing AngularJS and ReactJS_ Finding the Best Framework for your Next Pro...
JPLoft Solutions
 
React VS Angular- Which is Best for You in 2023?
CMARIX TechnoLabs
 
Angular vs React vs Vue
Hosein Mansouri
 
Angular vs react.pdf
Decoro Software Solutions
 
Professionalizing the Front-end
Jordi Anguela
 
Introduction to javascript technologies
Abdalla Elsayed
 
Ad

More from Orkhan Gasimov (11)

PPTX
Complex Application Design
Orkhan Gasimov
 
PPTX
Cloud Native Spring - The role of Spring Cloud after Kubernetes became a main...
Orkhan Gasimov
 
PPTX
Digital Transformation - Why? How? What?
Orkhan Gasimov
 
PPTX
Service Mesh - Why? How? What?
Orkhan Gasimov
 
PPTX
Angular Web Components
Orkhan Gasimov
 
PPTX
Vert.x - Reactive & Distributed [Devoxx version]
Orkhan Gasimov
 
PPTX
Vertx - Reactive & Distributed
Orkhan Gasimov
 
PPTX
Designing Fault Tolerant Microservices
Orkhan Gasimov
 
PPTX
Refactoring Monolith to Microservices
Orkhan Gasimov
 
PPTX
Fault Tolerance in Distributed Environment
Orkhan Gasimov
 
PDF
Spring Cloud: Why? How? What?
Orkhan Gasimov
 
Complex Application Design
Orkhan Gasimov
 
Cloud Native Spring - The role of Spring Cloud after Kubernetes became a main...
Orkhan Gasimov
 
Digital Transformation - Why? How? What?
Orkhan Gasimov
 
Service Mesh - Why? How? What?
Orkhan Gasimov
 
Angular Web Components
Orkhan Gasimov
 
Vert.x - Reactive & Distributed [Devoxx version]
Orkhan Gasimov
 
Vertx - Reactive & Distributed
Orkhan Gasimov
 
Designing Fault Tolerant Microservices
Orkhan Gasimov
 
Refactoring Monolith to Microservices
Orkhan Gasimov
 
Fault Tolerance in Distributed Environment
Orkhan Gasimov
 
Spring Cloud: Why? How? What?
Orkhan Gasimov
 
Ad

Recently uploaded (20)

PDF
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PDF
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
PDF
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PDF
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PDF
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
PPTX
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 

Angular or React

  • 1. Angular or React ? Which fits your needs?
  • 2. Speaker • Orkhan Gasimov, Software Engineer – 14 years of software engineering; – variety of technologies (languages & frameworks); – solution design and implementation; • Technology consulting and training: – Architecture. – Java. – JavaScript / TypeScript. • Author of training courses. – Spring Cloud. – Akka for Java.
  • 5. Agenda • Describe the difference of two. • Analyze an example project. • Overview core concepts. • Final decision making. • Questions & Answers
  • 7. Google – Angular • Google – many apps with single user id. • Angular – single framework with many features.
  • 8. Facebook – React • Facebook – single portal with many features. • React – many libraries for single application.
  • 10. Project • Imagine an example project with following functionality: – User logon; – Home page; – Settings page; – Data page; – Etc.
  • 11. Project • High-level project architecture consists of: – Web GUI; – REST API Server; – Database;
  • 13. Project • Web page oriented development
  • 14. Project • Web page oriented development – HTML pages loaded from server and rendered in browser.
  • 15. Project • Web page oriented development – HTML pages loaded from server and rendered in browser. – Navigation through pages.
  • 16. Project • Web page oriented development – HTML pages loaded from server and rendered in browser. – Navigation through pages. • Web experience oriented application development
  • 17. Project • Web page oriented development – HTML pages loaded from server and rendered in browser. – Navigation through pages. • Web experience oriented application development – Single page application – a desktop application with web experience.
  • 18. Project • Web page oriented development – HTML pages loaded from server and rendered in browser. – Navigation through pages. • Web experience oriented application development – Single page application – a desktop application with web experience. – Partial update of necessary regions, windows, panes.
  • 19. Project • Web page oriented development – HTML pages loaded from server and rendered in browser. – Navigation through pages. • Web experience oriented application development – Single page application – a desktop application with web experience. – Partial update of necessary regions, windows, panes. – Application loads once, only data is refreshed.
  • 20. Project • Web page oriented development – HTML pages loaded from server and rendered in browser. – Navigation through pages. • Web experience oriented application development – Single page application – a desktop application with web experience. – Partial update of necessary regions, windows, panes. – Application loads once, only data is refreshed. – URLs, back & forward navigation.
  • 21. Project • Web page oriented development – HTML pages loaded from server and rendered in browser. – Navigation through pages. • Web experience oriented application development – Single page application – a desktop application with web experience. – Partial update of necessary regions, windows, panes. – Application loads once, only data is refreshed. – URLs, back & forward navigation. – Caching, offline mode.
  • 24. Project • What is required? – JS toolkit that enables single page application development. – Reusable UI components support.
  • 26. Project • Web page decomposed to components
  • 32. Angular – Language • TypeScript @Component({...}) class MyComponent { constructor(private http:Http, private router: Router) { ... } }
  • 33. React – Language • JavaScript (ES5 / ES6) • TypeScript also supports React var MyComponent = React.createClass({ render: function() { ... } }); class MyComponent extends React.Component { render() { ... } }
  • 35. Angular – Approach • Angular is a framework with dependency injection. • The UI is component based. • Application is composed from components, services and other elements. @Component({...}) class MyComponent { constructor(private http:Http, private router: Router) { ... } }
  • 36. React – Approach • React is a library. • It is about components, and components. class MyComponent extends React.Component { render() { return <div>Component</div>; } }
  • 38. React • Component – Template • HTML block that should be rendered with this component. Angular
  • 39. React • Component – Template • HTML block that should be rendered with this component. – State • Private data that component should render or use for calculations. Angular
  • 40. React • Component – Template • HTML block that should be rendered with this component. – State • Private data that component should render or use for calculations. – Properties • Properties that may be passed from outside world to a component. Angular
  • 41. React • Component – Template • HTML block that should be rendered with this component. – State • Private data that component should render or use for calculations. – Properties • Properties that may be passed from outside world to a component. Angular
  • 43. Angular – Templates • HTML templates with JS code @Component({ selector: 'my-component', template: '<div>{{name}}</div>' }) class MyComponent { private name = 'Component'; constructor(private http:Http, private router: Router) { ... } }
  • 44. React – Templates • JSX – JS code with HTML markup const name = 'Component'; class MyComponent extends React.Component { render() { return <div>{name}</div>; } }
  • 45. State
  • 46. Angular – State • Component is an instance of a class. • State of object is the state of component. @Component({ selector: 'my-component', template: '<div>{{name}}</div>' }) class MyComponent { private name = 'Component'; updateName() { this.name = "Updated component"; } constructor(private http:Http, private router: Router) { ... } }
  • 47. React – State • Custom approach to state handling. class MyComponent extends React.Component { constructor() { this.state = {name: 'Component'}; } updateName() { this.setState({name: "Updated component"}); } render() { return <div>{this.state.name}</div>; } }
  • 49. Angular – Properties • Property syntax with @Input decorator should be used. <MyComponent [text]="Sample text"/> @Component({ selector: 'my-component', template: '<div>{{text}}</div>' }) class MyComponent { @Input() private text = 'Component'; }
  • 50. React – Properties • Special props object is available inside the component. <MyComponent text="Sample text"/> class MyComponent extends React.Component { render() { return <div>{this.props.text}</div>; } }
  • 54. What else? • Beyond Components
  • 55. What else? • Beyond Components – Events • Event oriented programming with custom application events.
  • 56. What else? • Beyond Components – Events • Event oriented programming with custom application events. – HTTP • We need somehow receive data from and send data to server.
  • 57. What else? • Beyond Components – Events • Event oriented programming with custom application events. – HTTP • We need somehow receive data from and send data to server. – Routing • Navigation over URLs requires different components to be rendered.
  • 59. Angular – Events • Framework supports event-oriented development with special constructs. <MyComponent (myEvent)="eventHandler(event)"/> @Component({...}) class MyComponent { @Output() myEvent: EventEmitter<string> = new EventEmitter<string>(); triggerEvent(event: string) { this.myEvent.emit(event); } }
  • 60. React – Events • Library does not support event-driven development out of the box. • There many third party libraries to use, as well as react adapted ones.
  • 61. HTTP
  • 62. Angular – HTTP • Framework provides HTTP module based on RxJS. @Component({...}) class MyComponent { constructor(private http:Http) { } getData(): Observable<DataItem[]> { return this.http.get("http://localhost/data") .map(response => response.json() as DataItem[]); }; }
  • 63. React – HTTP • Library does not provide HTTP support out of the box. • Native JS or third party libraries should be used. class MyComponent extends React.Component { getData() { fetch("http://localhost/data") .then(function (response) { return response.json() }) } }
  • 66. Angular – Routing • Framework supports routing out of the box. const appRoutes: Routes = [ {path: 'crisis-center', component: CrisisListComponent}, {path: 'hero/:id', component: HeroDetailComponent}, {path: '**', component: PageNotFoundComponent} ]; @NgModule({ imports: [RouterModule.forRoot(appRoutes)], ... }) export class AppModule { }
  • 67. React – Routing • Facebook developed react-router as separate library: • Third party libraries are also available. render( <Router history={browserHistory}> <Route path='/' component={App}> <IndexRoute component={Home} /> <Route path='admin' component={Admin} /> <Route path='genre' component={Genre} /> </Route> </Router>, document.getElementById('root') )
  • 71. Summary • In scope – Components • Templates
  • 72. Summary • In scope – Components • Templates • State
  • 73. Summary • In scope – Components • Templates • State • Properties
  • 74. Summary • In scope – Components • Templates • State • Properties – Events
  • 75. Summary • In scope – Components • Templates • State • Properties – Events – HTTP
  • 76. Summary • In scope – Components • Templates • State • Properties – Events – HTTP – Routing
  • 77. Summary • In scope – Components • Templates • State • Properties – Events – HTTP – Routing • Out of scope – Flux
  • 78. Angular • Angular – single framework with many features. – Dependency Injection; – Components; – Services; – Directives; – Pipes; – HTTP; – Router; – etc.
  • 79. React • React – many libraries for single application. – Components; – State handling; – Props handling; – JSX;
  • 80. React • Angular – single framework with many features. – Dependency Injection, Components, Services, Directives, Pipes, HTTP, Router and etc. • React – many libraries for single application. – Components, state and props handling + JSX. Angular