角度元素自定义元素显示,但项目中其他组件不显示

时间:2019-07-09 17:20:22

标签: angular angular-elements

我正在尝试使用Angular Elements从AngularJS进行迁移,并使AE自定义组件正常工作,我进行了合并,但它停止了工作。

自定义元素被加载,我可以从中看到文本,但是,我看不到任何角度组件或角度材质组件。构造函数和ngOnInit均会触发。因此,似乎找不到我的组件或角形材料。

app.module.ts

import { D6LargeMenuItemComponent } from "./component/d6-large-menu-item/d6-large-menu-item.component";
import { LargeMenuComponent } from "./component/large-menu/large-menu.component";
import { BrowserModule } from "@angular/platform-browser";
import { NgModule, Injector } from "@angular/core";
import { BrowserAnimationsModule } from "@angular/platform-browser/animations";
import {
  MatCardModule,
  MatButtonModule,
} from "@angular/material";

import { createCustomElement } from "@angular/elements";
import { D6OrderComponent } from "./component/d6-order/d6-order.component";

    @NgModule({
      declarations: [
        D6OrderComponent,
        LargeMenuComponent,
        D6LargeMenuItemComponent
      ],
      imports: [
        BrowserModule,
        BrowserAnimationsModule,
        MatButtonModule,
        MatCardModule
      ],
      entryComponents: [D6OrderComponent],
      providers: []

      // bootstrap: [AppComponent]
    })
    export class AppModule {
      constructor(injector: Injector) {
        const d6Order = createCustomElement(D6OrderComponent, { injector });
        customElements.define('d6-order', d6Order);
      }
      ngDoBootstrap() { }
    }

d6-order.companent.html

<div>
  <!-- this shows up -->
  d6-large menu 4
  <!-- this shows up -->
  <button mat-button color="primary">Primary</button>
  <!-- this shows up -->
    <button>dumb button</button>

  <d6-large-menu [itemList]='itemList'></d6-large-menu>
</div>

1 个答案:

答案 0 :(得分:0)

事实证明,其中一个组件中存在空注入(位置)错误。