Example _ AngularJS

Source: Internet
Author: User
This article mainly introduces some examples of implementing AngularJS commands in the JavaScript React framework. React uses VirtualDOM, which is somewhat different from the common js framework, for more information, see the ng-class:

 


Angularjs ng-class setting style code, which is easy to understand. How can we implement it using React?

First, set a variable such as isShowLoginMenu in state, change its value in different scenarios, and then bind it to the class style.

 

Or

  

With Angularjs, we can do this:

Logged On

Hello, {userName}

Not logged on



How can we implement such a scenario using React?

React. createClass ({getInitialState: function () {return {isLogin: true, userName: 'job'} ;}, render: function () {var isLogin = this. state. isShowLoginMenu, loginHtml; if (isLogin) {loginHtml =

Logged on. Welcome to {this. state. userName}

;} Else {loginHtml =

Not logged on

;} Return (

{LoginHtml}

);}
Related Article

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.