0

Think about this simple scenario:

<div ng-controller="ctrl1">
   ... drop down list...
</div>

<div ng-controller="ctrl2">
   ...grid list...
</div>

The first <div> contains a dropdown and the second <div> contains grid. According to the selected item in dropdown, ctrl2 should update the grid with new data. This is working great after loading, I fire event and catch it using $broadcast and $on.

BUT, I am having trouble doing the first load of the grid. The dropdown list loads with a list of items and the first item is selected by default, so the grid should show data according to that default selection. I can't use events here because if I fire event on $init of ctrl1, the $on of ctrl2 didn't initialized yet so it will not work. What is the right way to do this first load?

Please advice.

AngularOne
  • 2,760
  • 6
  • 32
  • 46
  • possible duplicate of [How can I pass variables between controllers in AngularJS?](http://stackoverflow.com/questions/12008908/how-can-i-pass-variables-between-controllers-in-angularjs) – Julien Jun 24 '14 at 09:39
  • Do you NEED to use different controllers? In that case, you can share info using a Service. – Mario Levrero Jun 24 '14 at 09:39

0 Answers0