Do you want to use react JS?-integration of angular and Reactjs

Source: Internet
Author: User

The MVC (Model-view-controller) pattern is a popular pattern in both the front and back of web development, Reactjs the View layer in the front-end MVC pattern, with a bit of a Controller layer feature, An HTML template that is equivalent to JavaScript writing. The data model and data binding are the advantages of angular, so angular and reactjs need to be integrated. However, Flux is a library that adapts to REACTJS data binding requirements, supports one-way data binding, https://facebook.github.io/flux/,Angular to HTML elements is two-way data binding, angular data binding advantage, The performance degradation occurs when too many HTML elements are misused and bound, because angular each render (render) iterates through all the HTML DOM elements, while the react virtual DOM can only change the parts that need to be updated without having to update them all every time.

Previously said, in angular JS integrated react JS Open Source Library: Https://github.com/ngReact/ngReact, this library is for the angular JS 1.3 version and the previous version, the author recommended react2angular , Angular2react, and Ngimport library are also for angular JS 1.6 version and previous version.

And Angular now version is 4, since 2015 released Angular 2 Angular JS is no longer called Angular JS and is called Angular to adapt to the development of the web and Mobile, Angular 2 and Angularjs 1 compared to the change is very large, Angular version modification record: https://github.com/angular/angular/blob/master/CHANGELOG.md, about angular 2 changes refer to this article: https:// Github.com/xufei/blog/issues/8.

In these two articles trying to integrate angular and Reactjs, Http://www.syntaxsuccess.com/viewarticle/integrating-react-with-angular-2.0,https ://www.packtpub.com/books/content/integrating-angular-2-react, there are at least two common ways:
1. Angular 2 has an optional hook-and-hook function, OnInit (), which can be triggered to render (render) Reactjs components.
2. after Angular 2, using atscript language based on typescript syntax, Typescript is a superset of JavaScript that supports ES6, static type checking, class characteristics, Common JavaScript libraries such as jquery have typescript type information definition files, Atscript and typescript are compiled into JavaScript as well, but they are more than typescript support for metadata annotations and runtime access to annotation information.
Typescript supports JSX compilation markup after 1.6 (the syntax used by REACTJS for JavaScript and HTML), and since angular and react are eventually compiled into JavaScript, angular and Reactjs code can visit each other during the compilation phase. Ask.

There is a lot of discussion on different JavaScript frameworks like Angular, React, etc these days, but one uniting FA ctor across frameworks seems to be TypeScript. As of TypeScript 1.6 The TypeScript compiler supports jsx out of the box. This was a huge help since it means we can manage both the Angular code and the React code in the same compilation step. The end JSX is valid TypeScript, that gets transpiled down to regular JavaScript. The only thing you has todo differently is tell the compiler that's the using JSX by specifying the JSX flag:

TSC--watch-m commonjs-t es5--emitdecoratormetadata--experimentaldecorators--jsx react app.ts

Do you want to use react JS?-integration of angular and Reactjs

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.