Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 在app.component.html中使用角度元素_Angular_Web Component_Angular Elements_Micro Frontend - Fatal编程技术网

Angular 在app.component.html中使用角度元素

Angular 在app.component.html中使用角度元素,angular,web-component,angular-elements,micro-frontend,Angular,Web Component,Angular Elements,Micro Frontend,我已经玩了一段时间的角度元素。我们的团队正在构建多个独立的角度项目,并将它们转换为角度元素。我们还构建了一个主shell,这些有角度的元素将在主shell中调用 主shell由Angular编写。到目前为止,我发现我只能将angular元素嵌入到主shell中的index.html中。但是,我想知道有没有一种方法可以使用app.component.html中的angular元素 mainShell中的index.html:在这里使用app1元素工作正常 提前谢谢 我明白了。要在app.compo

我已经玩了一段时间的角度元素。我们的团队正在构建多个独立的角度项目,并将它们转换为角度元素。我们还构建了一个主shell,这些有角度的元素将在主shell中调用

主shell由Angular编写。到目前为止,我发现我只能将angular元素嵌入到主shell中的index.html中。但是,我想知道有没有一种方法可以使用app.component.html中的angular元素

mainShell中的index.html:在这里使用app1元素工作正常


提前谢谢

我明白了。要在app.component.html中使用Angular元素,需要正确导入.js文件。有几种方法可以做到这一点,您可以使用SystemJS、dimport或使用JQuery进行静态导入。我的演示,我导入.js文件静态,请参考本文

<!DOCTYPE html>
<html lang="en">
  <head>
  ...
    <script src="../../elements/app1-element.js"></script>
  </head>
  <body>
    <app1-element></app1-element> 
  </body>
</html>
app1
--src
----app
------app.module.ts (customElements.define('app1-element', el);)
--package.json

mainShell
--src
----app
------app.component.html (I want to use 'app1-element' here)
----index.html
--package.json