Angularjs: call other scope which in iframe

前端 未结 4 2290
清酒与你
清酒与你 2020-11-27 13:44

In my test, given 2 document, A and B. In A document, there is an iframe, the iframe source is B document. My question is how to modify B document certain scope of variable?

4条回答
  •  半阙折子戏
    2020-11-27 14:45

    You should be able to get parent scope from iFrame:

    var parentScope = $window.parent.angular.element($window.frameElement).scope();
    

    Then you can call parent method or change parent variable( but remember to call parentScope.$apply to sync the changes)

    Tested on Angular 1.3.4

提交回复
热议问题