Hi Davide, I think what you are trying to do is a misuse of the $scope.$eval service. I googled around and the majority of suggestions around this question deal with creating a service and having the directive and controller interactive with the server separately. There are also several solutions that use $broadcast to fire an event in the directive that is listened for by the controller.
Check out this stack overflow for an example of the service solution: https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0CCgQFjAA&url=http%3A%2F%2Fstackoverflow.com%2Fquestions%2F14883476%2Fangularjs-call-method-in-directive-controller-from-other-controller&ei=AmhPU5LiOYqwyASrv4HoAg&usg=AFQjCNEIEh5ueaUjLlYrz7czulK2axL8OQ&bvm=bv.64764171,d.aWw cheers, Gordon On Wednesday, April 16, 2014 7:57:35 PM UTC-5, Michel Morelli wrote: > > Hi all, > > I have a custom directive. > > In my html i write this: > > > <uploader action="/rest/file/create_from_form.json" > success="writeFid()"></uploader> > > What I need is to exec "success" attribute function passing some parameter > data that I get from my directive. I can exec "success" attribute function > via > > $scope.$eval($scope.success) > > and in my "controller" I have this: > > $scope.writeFid = function (data) { > console.log("Into writeFid"); > console.log(data); //this is my problem: it is always undefined. > } > > I can see (via console.log() messages) that "success" function is called > but without passing "data". > > I have tried to use > > > <uploader action="/rest/file/create_from_form.json" > success="writeFid(data)"></uploader> > > but it does not work. > > So: how can i pass some type of $scope.data ? > > Thanks. > > -- > Davide Morelli > [email protected] <javascript:> > > > > > -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
