i think your link code is the interesting bit here, if you are calling scope.change outside of angular (on a browser event for example) then yes, you need to call scope.apply
On 7 June 2014 13:36, Francois Hattingh <[email protected]> wrote: > I have bound a function to a directive and in my isolated scope I specify > the &attr binding so I can trigger the external behaviour. What is the > correct way to trigger this function as I find that if I just invoke it > through scope.functionName() the watchers aren't triggered if scope changes > are made within the callback? > > e.g. > > in my directive I have scope: { change: &onChange } > from in my link method I call scope.change(); > > my html looks something like this <my-directive on-change="someFunction" /> > > in my controller > > $scope.someFunction = function(){ > $scope.someValueToUpdate = "update"; > }; > > anything watching $scope.someValueToUpdate doesn't get notified of the > change, unless I call scope.$apply() from my directive. > What would be the best way to do the scope.change() call from the > directive? > > -- > 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. > -- Tony Polinelli -- 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.
