Angular:将标记复制到外部标记

时间:2017-08-23 12:00:58

标签: angular

我正在将Angular-App A的标记集成到另一个应用程序B.这样可以正常工作。现在我想将应用程序A中组件的内容/标记“投影”到应用程序B中的html标记中 - 这显然不是我们应用程序的一部分。

这有可能吗?我正在使用ViewChild和createEmbeddedView - 但这似乎不适用于应用程序之外的目标容器:

@Component({
    selector: "ebc-app",
    templateUrl: "./app.component.html",
    styleUrls: ["./app.component.css"]
})
export class AppComponent {
    @ViewChild("clone") private template;
    @ViewChild("targetFooterContainer", { read: ViewContainerRef }) private container;

    constructor(@Inject("ISOLATED_RENDER_COMPONENT") public isolatedRenderComponent: string) {
    }

    private cloneTemplate() {
        this.container.createEmbeddedView(this.template);
        // container is undefined here
    }
}

0 个答案:

没有答案