Closed tuhlmann closed 1 year ago
Can you provide an example when the $scope of angular is needed inside react compontent? We're using v18 fork of this great project now for migration rather large angularjs app to the "shiny new world" of react and in all cases attribs is enough.
I've used $scope
inside React before, primarily to do $scope.$apply
and get mutations communicated back to AngularJS. I would assert this is an anti-pattern to be avoided but in some rare cases it was a lot more work to do it in a better way.
@tuhlmann Appreciate the heads up, I will update the README. I'm not sure if there's too much point in putting effort to fixing this but it's good to know.
@ornic We try to not use the $scope
in React componente, but for interaction that's sometimes needed. We used it to emit signals on or to catch events sent from an Angular component and these kinds of things.
@xjpro Don't worry too much about this problem. We mitigated by switching off production optimization, and I would assume that most people haven't heard of it before (I hadn't). It doesn't impact us right now.
Hey,
we discovered in our project that AngularJS will not inject the $scope into the React component if AngularJS's production optimizations are enabled.
These optimizations are described here: https://docs.angularjs.org/guide/production
The problem is, that the call to
.scope()
of an angular component will return null if debugging is disabled. It appears that this call to access the scope of a component was meant as a debugging aid- without making this obvious by the Angular designers.This is the offending line:
I'm not sure if there would be a workaround for this issue. Great if you know any, but we think we can live with this until all of the app is migrated.
Just thought to pass the info along, maybe you want to add this caveat to the Readme.
Thanks, Torsten.