Я хотел бы использовать рассмотреть возможность использования postMessage ...
В угловых терминах это означает, что одно приложение будет отправлять сообщения, а другой один будет слушать сообщения.
Так на приложение, которое сидит внутри фрейма вы можете сделать завод, который делает следующее:
/**
* App that sits within iframe:
*
* Inject this factory into your controller and call
* iFrame.messageParentIframe({hello: 'world'}) to send messages
* to the parent iFrame
*/
angular
.module('app')
.factory('iFrameMessenger', function($window) {
return {
messageParentIframe: function(message) {
$window.parent.postMessage(message, '*');
}
};
});
На родительском плавающем фрейме ваш код должен выглядеть примерно так:
/**
* App that is on parent iframe:
*
* Just using a controller for the sake of simplicity,
* but you could also use a Factory that only receives
* messages from iFrames and handle them according to each
* action, etc. You can get creative here on how you want
* to handle it.
*/
angular
.module('app')
.controller('AppCtrl', function($window) {
$window.addEventListener('message', function() {
// handle messages received from iframe
});
});
почему ты оказывают эти два приложения в двух разных iframe? Чего вы достигнете, выполнив это? –