【问题标题】:How to nest different modules in angular 2如何在角度2中嵌套不同的模块
【发布时间】:2019-11-08 00:51:17
【问题描述】:
The app.module has the admin-layout.module.
The admin-layout.module has the parameters.module.
The parameters.module has the soa-date.Component.
But the property.component is in the admin-layout.module

我需要将 <app-soa-date></app-soa-date> 选择器放在 property.component 中,但它给了我一个错误 app-soa-date is not a known element。

<div class="card-body">
  <div *ngIf="showSoaDate">
    <app-soa-date></app-soa-date>
  </div>
  <div *ngIf="showOther">
    Other
  </div>
</div>

请看下图:

谢谢。

【问题讨论】:

    标签: javascript angular typescript ecmascript-6 single-page-application


    【解决方案1】:

    您也需要在 ParamatersModule 中导出组件

    declarations: [
    ....
    ],
    exports: [
      SoaDateComponent 
    ]
    

    【讨论】:

    • 这个答案有错别字。请将declearations 更改为declarations
    【解决方案2】:

    您需要从您的ParametersModule 导出SoaDateComponent 组件。

    exports: [
      SoaDateComponent
    ] 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-26
      • 2016-03-13
      相关资源
      最近更新 更多