Implement some examples of ANGULARJS in the React framework _angularjs

Source: Internet
Author: User

First set the Ng-class of a ANGULARJS code:

 
 


Easier to understand the Angularjs Ng-class set style code, then how do we use react to implement it?

First set a variable in state such as: Isshowloginmenu, change its value in different scenes, and then bind to the class style

<i classname={"Header-help-icon down" + (This.state.isShowLoginMenu? ' Up ': '}></i> 

Or

 
<span id= "Vip-header-logo" classname={' Vip-logo icon-vip-v ' + this.state.viplevel}></span> 

Using Angularjs We can do this:

<div class= "logined" ng-show= "IsLogin" > Login </div> <div class= "logined" 
ng-if= "IsLogin" > Hello, { username}</div> 
<div class= "No-login" ng-hide= "IsLogin" > Not signed in </div> 



So how do we use react to achieve such a scenario?

React.createclass ({ 
 getinitialstate:function () {return 
  { 
   islogin:true, 
   userName: ' Joe ' 
  }; 
 } , 
 
 render:function () { 
   var islogin = this.state.isShowLoginMenu, 
   loginhtml; 
 
   if (islogin) { 
    loginhtml = 
     <div classname= "logined" > 
      login, Welcome to {this.state.userName} 
     </ div>; 
   } else { 
    loginhtml = 
     <div classname= "No-login" > 
      not logged in 
     </div>; 
   } 
 
  Return ( 
    <div classname= "user" > 
     {loginhtml} 
    </div> 
  ); 
 } 

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.