Open LuciferZhang opened 8 years ago
I just now have encountered a similar problem. Apparently within a flow div, the scope is isolated. The only way you can get to the image(or any other $scope variable) is to pass it to a function and handle it over there.
+1
have any of you identified the issues and want to propose a patch?
Well instead of creating a child scope(which inherits from the parent but won't allow two-way binding) in the flow-init directive, you could create an isolate scope where a flow object is defined with =. That way you could expose the flow object to the parent scope. Like so:
.directive('flowInit', [function() { return { scope: { $flow: '=' }, controller: 'flowCtrl' }; }]);
This way, the user can have access to the flow object and name it however they want, and because it is isolated, it will still work with multiple directives on the same page.
Usage would be:
<div flow-init $flow="my-flow-object">
and if you wanted to view the image before uploading it, like OP, you would do:
<img flow-img $flow='my-flow-object'>
You would need to alter the flow-img directive as well.
I'm not sure if this will cause any conflict and I'm currently not able to actively help, but this would be the way to handle multiple directives without contaminating the scope and still make the flow objects available outside of flow-init, which apparently is sometimes needed.
why i can not get {{myCroppedImage}} outside ng-flow scope? and how can i get the var at outside ng-flow scope which inside ng-flow scope? anyone else has the same question?