I'm not asking about technical specifics here, but rather a design / 
architectural opinion.  I want to learn if I am doing things the 'angular 
way'.

Lets say I have a single page application that has an alert mechanism 
(using angular ui alert, hovers over at top of page then disappears after a 
few seconds).  Point is: there is only one of them.

I have something like this: <div 
ng-controller='alertController'><alert...>blah</alert></div>.  And in the 
controller, it simply listens for broadcast messages indicating an alert 
should be shown.  It works, the controller is testable, and its trivial for 
clients create an alert eg: $scope.$root.broadcast({msg:'blah', 
type:'success');

The other option is to create a directive, and I would end up with just 
<myAlert></myAlert>, and everything else pushed to the directive.  This is 
kind of neat, but something doesn't feel right when I create a directive 
when there can only ever be one of them, and it is receiving broadcast 
messages.  Keep in mind it is other controllers that will be pushing the 
messages.

Are there any pitfalls with the directive approach (app controllers 
communicate with directive controllers ?).

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