I have a page A, which contains two iFrames B and C. Both B and C are trusted and under my control. B and C each use AngularJS. I'd like to use the scope of an inner element on page B as the scope for an element on page C.
More concretely,
Page A:
...
<iframe src="Page B"/>
<iframe src="Page C"/>
...
Page B:
...
<div id="trunk-element" ng-controller="PageBController">
{{pageBModel.text}}
</div>
...
Page C:
...
<div id="grafted-element">
{{pageBModel.text}}
</div>
...
How do i get #grafted-element to "take on the scope" of #trunk-element? That is, I'd like #grafted-element to act exactly as if it was included inside #trunk-element on page B. I have a reference to #trunk-element's scope in page C.
Some stuff I've tried:
Overwriting the '$scope' data attribute of #grafted-element. This gets reverted.
Creating a controller on page C for which I replace the $parent and __proto__ properties of $scope to #trunk-element's scope. Then I enclose #grafted-element in that controller. This works, but the rendering does not update when pageBModel.text changes.
$scope.pageBText = angular.element(parent.iFrameBName.getElementById("trunk-element")).scope().text? Then maybe you would have to set up a$watch, not sure.