There is the following question: I have an outer controller (HomeController) and an internal controller (PostsController). Can I get access and change variable in HomeController from PostsControlle r? I know that I can read HomeController's variable from PostsController, but what's about writing? Thanks in advance.
Asked
Active
Viewed 148 times
0
-
try to use `Scope`' `$broadcast` and `$emit` : http://stackoverflow.com/questions/19038778/angularjs-how-to-call-child-scope-function-in-parent-scope/19038906#19038906 – Ivan Chernykh Dec 01 '14 at 13:07
-
I'd consider using an event of some sort rather than reaching directly into a parent scope. – Dave Newton Dec 01 '14 at 13:08
-
Do you prefer this feature instead of using rootScope? – malcoauri Dec 01 '14 at 13:11
1 Answers
1
- Parent scope variables are available via $parent so you can change those in the child directive.
- You can use $emit to propagate the value you want to change to the parent controller. You need to use $on to subscribe to the event.

Kiran P
- 299
- 2
- 11