2

Using Angular's standard route I was able to have child controllers access the parent $scope:

<div ng-controller="ParentCtrl">
    <ng-view></ng-view>
</div>

Any Child controllers within ng-view would be able to access the ParentCtrl Data, but with the Angular 1.5 Component Router this doesnt seem like the case. The only difference in the above markup is instead of ng-view it's ng-outlet.

Does anyone know how to access Parent Controller information within a Child Controller based in an ng-outlet in the Component Router? Or is there any other way to access parent data?

HireLee
  • 561
  • 1
  • 9
  • 25

1 Answers1

0

you can try $rootScope for your case

  • So I'd set the parent data to $rootScope and access that $rootScope variable within a child controller? I always thought accessing $rootScope to be bad practise? – HireLee May 16 '16 at 09:16
  • i don't think so, i always call $rootScope variable. Why do you think it is bad practice? – Quốc Hồ Thanh May 16 '16 at 09:18
  • http://www.thinkingmedia.ca/2015/01/learn-how-to-use-scopes-properly-in-angularjs/ This link give a run-down on $rootScope and potentially the issues of assigning variables to it. – HireLee May 17 '16 at 09:01