When you do this, be sure of the fact that $emit/$broadcast wont work from one controller to the other because there is no parent / child relationship.
One hacky-way, in such situations is to do $scope.$parent.$broadcast(...) kind of thing. You may have guess that the controller emitting the event can also listen to it since both the controller have a common parent :) On Thursday, November 29, 2012 at 12:19:48 PM UTC-8, Pete Bacon Darwin wrote: > > You can create any number of directives that create "directive > controllers" and apply them all to the same element. > > http://plnkr.co/edit/0DxvAb?p=preview > > Pete > > > On 29 November 2012 16:35, Jim Hoskins <[email protected] <javascript:>> > wrote: > >> Why exactly do you need this? Are there places you would use ctrl1 OR >> ctrl2 and not both? Nesting one of the controllers in the other should >> work, unless you are doing some very specific things in which case it may >> not. >> >> You could, and I don't know if this is the best way to go, write a 3rd >> controller, that is composed of the other two. Basically instantiate ctrl1 >> and ctrl2 from ctrl3, passing through the $scope, $element, $attrs, and >> $transclude. >> >> Heres a plunker of it http://plnkr.co/edit/79GOUe?p=preview >> >> >> On Thursday, November 29, 2012 10:10:22 AM UTC-5, Nina wrote: >>> >>> I need call two controllers (ctrl1, ctrl2) on the same div(id="div1"), >>> if its possible, how can i do it? >>> >>> <div id="div1" ng-controller="ctrl1"> >>> ... >>> </div> >>> >>> thx all >>> >>> Nina >>> >> -- >> You received this message because you are subscribed to the Google Groups >> "AngularJS" group. >> To post to this group, send email to [email protected] >> <javascript:>. >> To unsubscribe from this group, send email to >> [email protected] <javascript:>. >> Visit this group at http://groups.google.com/group/angular?hl=en-US. >> >> >> > > -- 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.
