The way to control a directive from a controller is to pass all the things
that are necessary for the directive through attributes. Change the
attributes to change the behaviour of the directive.

Do not go with $scope.$emit blindly - Angular's eventing mechanism is a
last step fall back that you would use for some other scenarios but not for
communicating with a directive in most cases. Also, how close the directive
and controllers are in the DOM is quite important in determining which
method to use.


On Fri, Jun 13, 2014 at 8:05 AM, Sergio Castillo Yrizales <
[email protected]> wrote:

> Hi Sander
> There are three Angular way for communication
> 1. use of scope.emit on directive and scope.broadcast on controller
> 2. create a service and inject in both.
> 3. Using scope for sharing things.
> From this three the cleanest one is the first one because it helps you to
> separate concerns and not to populate the scope with unnecessary watches.
> Remember that every watch that we setup slows down the application because
> they run on every digest cycle.
> I hope this help.
>
> --
> 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.
>



-- 
Regards,
Ganaraj P R

-- 
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.

Reply via email to