0

我正在尝试使用 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>
4

1 回答 1

0

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

于 2019-07-10T15:35:25.140 回答