You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 28, 2019. It is now read-only.
@mackenrou how about this modified version of the Hello example
varapp=angular.module('app',['react']);app.controller('mainCtrl',function($scope){$scope.person={fname: 'Clark',lname: 'Kent'}// add function to scope$scope.changeName=function(){$scope.person={fname: 'Bruce',lname: 'Banner'};};});varHello=React.createClass({propTypes: {fname: React.PropTypes.string.isRequired,lname: React.PropTypes.string.isRequired,changeName: React.PropTypes.func},onClick: function(e){// process event here// now call function from props // this is the change name function declared on the controllers scopethis.props.changeName();},render: function(){return<div>
Hello {this.props.fname}{this.props.lname}<buttononClick={this.onClick}>Change Name</button></div>);}});app.value("Hello",Hello);app.directive('hello',function(reactDirective){returnreactDirective(Hello);});
How to call a scope function from react component?
Could you put a simple example of how to call a function in angular controller from onClick event of a react component?
Thanks in advance!
The text was updated successfully, but these errors were encountered: