I've worked out the solution. The problem was that $apply works at root scope so it is not limited to the scope of a particular controller.
The solution I came up with was to remove $scope from the callback function and within the callback function call $digest. This way, $digest is limited to the scope of the current controller and does not trigger the watchers for any other scope. On Thu, Apr 2, 2015 at 9:44 AM, Tandon, Rishi <[email protected]> wrote: > why should modifying the scope of one controller effect the other? > > To avoid that, use ISOLATED scope, > refer: > http://onehungrymind.com/angularjs-sticky-notes-pt-2-isolated-scope/ > > On Thu, Apr 2, 2015 at 9:38 AM, hingorjo mr <[email protected]> wrote: > >> Thanks. But I was under the assumption that each controller will have a >> separate scope. I'm not using nested controllers. If this is a valid >> assumption, then why should modifying the scope of one controller effect >> the other? >> >> On Thu, Apr 2, 2015 at 1:49 AM, Sander Elias <[email protected]> >> wrote: >> >>> Hi, >>> >>> You are right. This is because of $scope.$apply That’s the reason you >>> should use it as sparingly as possible. an $apply will make sure that >>> every watch in your application is fired at least once. The reason is, that >>> in your eventBCallback you might have changed something that otherwise >>> might get unnoticed, (lets assume you add a new module to the modules >>> array (yeah I know that isn't easy possible,but angular does not!)) and >>> therefore the filters need too be fired also. >>> >>> If you are really sure that what you are doing in your evenBCallback >>> does not affect other places, but indeed only the local scope, you can sue >>> $scope.$digest() in stead of $scope.$apply, but you better be sure you >>> know what you are doing! >>> >>> Regards >>> Sander >>> >>> >>> -- >>> You received this message because you are subscribed to a topic in the >>> Google Groups "AngularJS" group. >>> To unsubscribe from this topic, visit >>> https://groups.google.com/d/topic/angular/FCyO0IMU-g0/unsubscribe. >>> To unsubscribe from this group and all its topics, 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. >>> >> >> -- >> 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. >> > > > > -- > *Rishi Tandon* > Pearson Learning Technology Group > > Mobile: (310) 926-9032 > > Pearson > Always Learning > Learn more at www.pearson.com > > -- > You received this message because you are subscribed to a topic in the > Google Groups "AngularJS" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/angular/FCyO0IMU-g0/unsubscribe. > To unsubscribe from this group and all its topics, 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. > -- 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.
