Angular分模块部署到docker

以Portal与login模块为例子

Portal的Controller中:

var nodeIp ="localhost";
var htmldata = '<iframe height="1500" class="container col-sm-12 "  src="http://' + nodeIp + ':3002/index"></iframe>';

//src为login模块首页地址,3002为login模块所在端口

$scope.html = htmldata;
$scope.visible = !$scope.visible;

  

index.html中:

<div class="form-group-my" ng-show="visible" compile="html"></div>

  

Login登录后将用户信息放入redis中,此时Portal需刷新才可获得redis中的用户信息,即Login需向Portal模块返回信息

涉及到iframe跨域问题,子页需要调用父页的刷新方法,百度找到解决问题

Login的Control中登录之后:

if(typeof(exec_obj)=='undefined'){
exec_obj = document.createElement('iframe');
exec_obj.name = 'tmp_frame';
exec_obj.src = 'http://localhost:3000/public/views/execA.html';

//src为Portal模块首页地址,3000为Portal模块端口
exec_obj.style.display = 'none';
document.body.appendChild(exec_obj);

}else{
exec_obj.src = 'http://localhost:3000/public/views/execA.html?' + Math.random();
}

  

在Portal模块中新建文件exeA.html

内容为下:

<script type="text/javascript">
parent.parent.test();// execute parent myframe fIframe function
</script>

Portal中的index.html加入以下:

<script type="text/javascript">

function test() {
window.location.reload();

};

</script>

  

此时当登录完成后Portal首页会刷新,即可从redis中取出用户信息

参考地址: http://blog.csdn.net/fdipzone/article/details/17619673