diff --git a/README.md b/README.md index ed9f13d..9a3c1ae 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,37 @@ If `propTypes` are defined and you passed in a 2nd argument, the argument will o > ``` +## Dependency Injection + +It's easy to pass services/constants/etc. to your React component: just pass them in as the 3rd argument, and they will be available in your component's Props. For example: + +```js +import { Component } from 'react' +import { react2angular } from 'react2angular' + +class MyComponent extends Component { + state = { + data: '' + } + componentDidMount() { + this.props.$http.get('/path').then(res => + this.setState({ data: res.data }) + ) + } + render() { + return
+ { this.props.FOO } + { this.state.data } +
+ } +} + +angular + .module('myModule', []) + .constant('FOO', 'FOO!') + .component('myComponent', react2angular(MyComponent, [], ['$http', 'FOO')) +``` + ## Tests ```sh diff --git a/package.json b/package.json index 966b8db..13e4194 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react2angular", - "version": "3.0.2", + "version": "3.1.0", "description": "The easiest way to embed React components in Angular 1 apps!", "main": "index.js", "main:esnext": "index.es2015.js",