Table of Contents |
---|
Key Points
References
Reference_description_with_linked_URLs_______________________ | Notes______________________________________________________________ |
---|---|
Angular Compare Key Difference Between Angular 6 Vs Angular 7 Vs Angular 8 Vs Angular 9.pdf gdrv | Angular version comparisons 6 - 7 - 8 - compare |
Angular Compare-AngularJS vs Angular2 Features and Comparison gdrv | AngularJS vs Angular 2 - compare |
https://blog.angular-university.io/introduction-to-angular-2-forms-template-driven-vs-model-driven/ Angular Forms Guide - 2929 - Template Driven and Reactive Forms gdrv | Angular Template Forms vs Angular Reactive Forms |
https://programmingwithmosh.com/react/react-vs-angular/ | compare angular and react - p1 |
https://rubygarage.org/blog/react-vs-angularjs | compare angular and react - p2 |
https://angular-university.io/my-courses | Free Angular Beginner course - login w github jmason90 |
Key Concepts
Compare Angular and React
https://programmingwithmosh.com/react/react-vs-angular/
...
- React-router for routing
- Redux or MobX for state management
- Enzyme for additional testing utilities
DOM vs Virtual DOM
React's virtual DOM has fast updates to the specific items in the DOM
Angular updates the full DOM until all the changed items have been updated - slower
Templates
React decided to combine UI templates and inline JavaScript logic, which no company had ever done before. The result is called “JSX”
...
Angular uses templates that are enhanced HTML with Angular directives (“ng-if” or “ng-for”). React only requires knowledge of JavaScript, but with Angular, you must learn its specific syntax.
Components
Both React and Angular are both component-based. A component receives an input, and after some internal logic returns a rendered UI template (a sign-in form or a table for example) as output. Components should be easy to reuse within other components or even in other projects
State management
The UI is described by the component at a given point in time. Then, the framework re-renders the entire UI of the component when data changes. This ensures that the data is always up to date.
To handle state in React, Redux is often used as the solution. In Angular, you may not need Redux. But, if your application becomes large enough, chances are that you will. Some developers, including me, opt to use MobX instead of Redux. MobX has more “magic” (things automatically done for you behind the scenes) and I personally prefer it.
Data Binding
A large difference between React and Angular is one-way vs. two-way binding. Angular uses two-way binding. For example, if you change the UI element (a user input) in Angular, then the corresponding model state changes as well. Additionally, if you change the model state, then the UI element changes – hence, two-way data binding.
Angular
When we bind values in HTML with our model, AngularJS creates a watcher for each binding to track changes in the DOM. Once the View updates (becomes “dirty"), AngularJS compares the new value with the initial (bound) value and runs the $digest loop. The $digest loop then checks not only values that have actually changed, but also all others values that are tracked through watchers. This is why performance will decrease a lot if your application has too many watchers.
This drawback is even more painful when several values (Views) are dependent on each other
React
React does not update the model when the UI changes - 1 way data binding
React only has one-way binding. First, the model state is updated, and then it renders the change in the UI element. However, if you change the UI element, the model state DOES NOT change. You must figure that out for yourself. Some common ways are through callbacks or state management libraries
to implement a unidirectional data flow in React, Facebook created its own application architecture called Flux. Flux controls the flow of data to React components through one control point – the dispatcher. Flux's dispatcher receives an object (they call it an action) and transfers it to an appropriate store, which then updates itself. Once the update is finished, the View changes accordingly and sends a new action to the dispatcher. It's only possible to transfer an action to the store when it’s fully updated. With this concept, Flux improves the effectiveness of the code base. Based on our own experience we can say that Flux is great when you work with dynamically updated data.
Typescript vs Javascript Flow
React uses JavaScript, a dynamically-typed language (which means you don’t have to define the variable’s type). Because many developers already know and love JavaScript, this can be seen as a pro. With ES6, you have modules, classes, spread operators, arrow functions, template literals and more. It allows developers to write declarative code while having the characteristics of a true OOP language (that is, including class-based structure).
...
// JavaScript (ES6)
function getName(name, age){
return name + age;
}
// TypeScript
function getName(name: string, age: number){ // <-- static typed!
return name + age;
}
================================
Classes in Javascript vs Typescript
// JavaScript (ES6)
class Greeter {
constructor(message) {
this.greeting = message;
}
greet() {
return "Hello, " + this.greeting;
}
}
let greeter = new Greeter("JavaScript!");
greeter.greet()
// Hello, JavaScript!
================================
// TypeScript
class Greeter { // <-- static typed!
greeting: string;
constructor(message: string) {
this.greeting = message;
}
greet() {
return "Hello, " + this.greeting;
}
}
let greeter = new Greeter("TypeScript!");
greeter.greet()
// Hello, TypeScript!
Mobile Apps
Angular and React both offer solutions to create mobile applications.
...
React Native, on the other hand, is a platform developed by Facebook for creating truly native mobile applications using React. The syntax is slightly different, but there are much more similarities than differences. Unlike Ionic, which is simply a glorified web app, React Native produces a truly native UI. It also allows you to create your own components and bind them to native code written in Objective-C, Java, or Swift.
Testing frameworks
Jest is used by Facebook to tests its React code. It is included in every React project and requires zero configuration to use. It also includes a powerful mocking library. Many times Jest is used in combination with Enzyme (a JavaScript testing utility used at Airbnb).
Jasmine is a testing framework that can be used in Angular. Eric Elliott says that Jasmine “results in millions of ways to write tests and assertions, needing to carefully read each one to understand what it’s doing”. The output, in my opinion, is also very bloated and difficult to read. Here are some educational articles on the integration of Angular with Karma and Mocha.
Dependency Management
Angular
Angular has built-in management
AngularJS uses a basic Object Oriented Programming (OOP) pattern called dependency injection, meaning we write dependencies in a separate file. It’s inconvenient to create a dependency directly in an object. In AngularJS, dependency injection is inherent to any standard functions that we declare for an AngularJS factory or service. We only pass dependencies as parameters in any order in our functions.
React
React needs 3rd party tool like renovate
The difference between React and AngularJS with regards to dependency injection is that React doesn’t offer any concept of a built-in container for dependency injection. But this doesn't mean we have to think of a method to inject dependencies in our React project. You can use several instruments to inject dependencies automatically in a React application. Such instruments include Browserify, RequireJS, EcmaScript 6 modules which we can use via Babel, ReactJS-di, and so on. The only challenge is to pick a tool to use.
Learning process
React
The first thing you’ll learn in React is JSX. It may seem awkward to write at first, but it doesn’t add much complexity. You’ll also need to learn how to write components, manage internal state, and use props for configuration. You don’t need to learn any new logical structures or loops since all of this is plain JavaScript.
...
It may seem like React has a lower barrier for entry, and I would most certainly have to agree. However, that doesn’t mean that React is “better”. I encourage you to try both React and Angular to see which one you personally prefer.
what frameworks are developers interested in? 2018
Summary
Angular:
- Is a full framework
- Has a Regular DOM, which renders updates slower than React’s Virtual DOM
- The rendered JavaScript and HTML maintains a physical separation
- Utilizes Components: emerging web components standard
- Data Binding: two-way
- You must use TypeScript
- Mobile: Ionic and Cordova are slower than React Native
- Testing: Jasmine & Mocha
- Learning Curve is higher, but once you understand it you have an entire MVC framework
- Scalability: easy to scale
- Popularity: dropped since AngularJS (Angular 1)
- Open source: GitHub stars: 40,963 / Contributors: 732 / Issue: 2,162
- Size: larger, resulting in longer load times and performance on mobile
- Used on: Google, Nike, Forbes, Upwork, General Motors, HBO, Sony
...
- Just a small view library
- Has a Virtual DOM, which renders updates faster than Angular’s Regular DOM
- Uses JSX, which combines markup and logic in the same file (making components easier to read)
- Components: emerging web components standard
- Data Binding: one-way
- You Can use ES6/7 JavaScript, although you can use Typescript or Flow if you so choose
- Mobile: React Native is faster than Angular’s solutions
- Testing: Jest & Enzyme
- Learning Curve is lower, but you only get the view. Because of this, you’re going to have to learn a slew of 3rd party libraries. Ex. State management (Redux or MobX), Asynchronous calls (react-promise, react-thunk, or react-saga), etc.
- Scalability: is more testable, so also easy to scale
- Popularity: has increased exponentially
- Open source: GitHub stars: 111,927 / Contributors: 1,242 / Issues: 287
- Size: smaller than Angular, so a bit faster
- Used on: Facebook, Airbnb, Uber, Netflix, Instagram, Whatsapp, Dropbox
- React Fiber will increase the speed of React dramatically
Mosh's React Course
https://codewithmosh.com/p/mastering-react
$29 one time payment for course
Angular
Angular Universal Course
We will continue to publish new video lessons weekly until the course is completed. In this weeks sample video lesson we will start at the beginning and give you a detailed answer to the question:
Click Here to Watch: What is Angular Universal?
What is Angular Universal?
In a nutshell, Angular Universal is a node-based rendering engine for Angular.
It can be used in two different ways:
- we can use it for on the fly server-side rendering, by integrating it with a Node server, for example, an Express engine. Angular Universal can be used to create the HTML of a given Angular application page on the client-side, before sending it over the wire to the client, instead of a blank page like a standard single page application
- A much more interesting use case though is to use it for build-time pre-rendering. We can pre-render a series of application routes (both static and dynamic), and serve those files statically from a plain HTTP web server, without needing a Node process running on the backend
This is the gist of it, but you will find a much more detailed explanation in the video above.
Another question that you probably have is, when to use Angular Universal and why?
We will be covering that and more in the next few sample video lessons, that you will be receiving in the next coming weeks.
Please enjoy this week's video, I want to thank you for reading and wish you an awesome weekend!
Kind Regards,
Vasco
Angular University
React
Potential Value Opportunities
Potential Challenges
Candidate Solutions
Step-by-step guide for Example
Info |
---|
sample code block
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
Recommended Next Steps
Related articles
Page Properties | ||
---|---|---|
| ||
|
...