How to access a variable of child directive in parent directive? I have a parent directive like:
<parent-directive>
<child-directive></child-directive>
</parent-directive>
child directive contains an object "states.visible" I want to access that in parent directive.
I think the AngularJs way of doing this would be accomplished with implementing an output in the child directive. Every time the "states" object changes the child calls the output function and the parent can do whatever it wants with it.
AngularJS v1.5+ Method:
HTML
Child Controller
Parent Controller
https://docs.angularjs.org/guide/component#component-based-application-architecture
Prior to AngularJS v1.5 Method:
this should technically work the same with a two way bound function. except the html would look like this
instead of
. then in the child it would be
instead of