Giter Site home page Giter Site logo

angular-react's Introduction

angular-react Build Status

This project is for those wishing to integrate AngularJS using ReactJS, a performant view layer that can play well with a popular MV* framework for complex web applications.

This is currently a rough WIP.

Setup

  • (Recommended) Install react-tools via npm install -g react-tools
  • (Recommended) Run jsx --watch src/ dest/ (source and destination directories - stub paths as needed)

Usage

To use this library, one must inject the $react helper service into your directive. $react is a wrapper around the React api that implements a createClass method, which registers the React component class and creates a directive object. If the component is already registered, it will return you the component.

Example

/* hello directive - lives in separate file for JSX to compile */
module.directive('hello', function ($react) {
  return $react.createClass('hello', {
    render: function () {
      /** @jsx React.DOM */
      var person = this.props.person || 'World';
      return (
        <div>Hello {person}!</div>
      );
    }
  });
});

/* Scripts */
module.controller('DemoCtrl', function ($scope) {
  $scope.props = {
    person: 'Wesley'
  };
});

/* html */
<hello></hello> // renders <div>Hello World!</div>
<hello props="props"></hello> // renders <div>Hello Wesley!</div>

API

$react.createClass(componentName, reactClass, options) - function that takes a componentName, React component class, and options and returns a directive object back

$react.renderComponent(scope, element, attributes) - function that takes a $scope, element, and attributes. These are the same arguments passed in by a linking function in a directive.

angular-react's People

Contributors

wesleycho avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

angular-react's Issues

Injected service naming issue

I would strongly recommend not naming the service $react, and instead opt for ReactService or something similar. According to the AngularJS documentation:

The $ prefix is there to namespace Angular-provided services. To prevent collisions it's best to avoid naming your services and models anything that begins with a $.

Question : why postpone React rendering ?

Hi,

I'm testing React integration in an Angular in a very close way you do, but I don't found the use to postpone the rendering of the React component, you do using $$postDigest.

What is the reason behind that please ?

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.