首页 > 解决方案 > 在窗口弹出窗口中打开时,ckd-overlay-container 不起作用

问题描述

我正在从 angularjs 打开 angular2 组件,因为 angularjs 一个是我的遗留应用程序,我有一个要求,我需要在窗口中显示一些新的 angular2 组件。我找到了一个解决方案,我可以使用该组件打开一个新窗口。

angular.module('myModule').factory('popupWindow', ['$rootScope', '$compile', '$window',
        function ($rootScope, $compile, $window) {
            var html = '<survey></survey>';
            var link = $compile(html); // note that compilation happens only once

            return {
                open: function () {
                    var scope = $rootScope.$new(true);

                    var w = $window.open('', '_blank', 'toolbar=0,width=1250,height=600');
                    copyStyles(document, w.document);

                    // using a cloneAttachFunction, cf. the docs and http://stackoverflow.com/questions/18064543/compile-angular-on-an-element-after-angular-compilation-has-already-happened
                    link(scope, function (cloned, scope) {                            
                        angular.element(w.document.body).append(cloned);                           
                    });
                }
            };
        }]);

但我现在遇到了另一个问题。该组件具有 md-autocomplete 并且当我单击它时打开 md-options 但它们与父主应用程序绑定当我查看开发人员工具时 cdk-overlay-container 附加到父应用程序而不是从它打开的子窗口。有什么解决方案吗?https://material.angularjs.org/latest/用于此。 附在此处的图片

标签: angularjsangularjs-material

解决方案


推荐阅读