Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to pass a callback with &? #3

Closed
korya opened this issue Mar 31, 2017 · 3 comments
Closed

Is there a way to pass a callback with &? #3

korya opened this issue Mar 31, 2017 · 3 comments
Labels

Comments

@korya
Copy link

korya commented Mar 31, 2017

Is there a way to pass a callback to angular component from react component?

I have an angular component that is a child of react component. The mapping from the parent (react) to the child (angular) works fine with < bindings. What I need is the other way communication: from the child (angular) to the parent (react) with '&' bindings. Is there a way to do it?

@korya
Copy link
Author

korya commented Mar 31, 2017

When I pass the callback with &, the communication from child to parent is broken. However when I pass it with < or =, it works: the callback provided in react props is being called. The question is how robust this approach is. What do you say?

I am not too familiar with angular internals, so I would like to hear an opinion from someone more experienced.

@bcherny
Copy link
Contributor

bcherny commented Mar 31, 2017

Hi @korya. Unfortunately, React only supports 1-way bindings (<). The idea is to simplify the way data flows by eliminating 2-way bindings (=) and expression bindings (&).

Expression bindings are really a type of 1-way binding. You can update your code to use < bindings instead. For example:

// before
<component onClick="onClick(value)"></component>

// after
<component onClick="onClick"></component>

I hope that helps!

@korya
Copy link
Author

korya commented Apr 2, 2017

OK. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants