我生成了一個空白的應用程序使用離子開始。這運行良好。離子3角度未處理的承諾拒絕:模板分析錯誤:
現在我添加了一個名爲opty的新頁面,使用 離子g頁面opty。
創建一個導航使用navpush從home.html到opty.html點擊按鈕。很棒。現在
,我添加使用組件: 離子克組分opty頭
所有細直到這裏。現在,如果這包括在opty.html作爲
它結束了錯誤:
Unhandled Promise rejection: Template parse errors:
'opty-header' is not a known element:
1. If 'opty-header' is an Angular component, then verify that it is part of this module.
2. If 'opty-header' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("
<ion-content padding>
[ERROR ->]<opty-header></opty-header>
</ion-content>
"): ng:///AppModule/[email protected]:2 ; Zone: <root> ; Task: Promise.then ; Value: Error: Template parse errors:
'opty-header'
我opty.module.ts看起來像
import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { OpportunitiesPage } from './opportunities';
import { ComponentsModule } from '../../components/components.module'
@NgModule({
declarations: [
OpportunitiesPage,
],
imports: [
IonicPageModule.forChild(OpportunitiesPage),
ComponentsModule
],
})
export class OpportunitiesPageModule {}
我components.module.ts看起來像
import { NgModule } from '@angular/core';
import { OptyHeaderComponent } from './opty-header/opty-header';
@NgModule({
declarations: [OptyHeaderComponent],
imports: [],
exports: [OptyHeaderComponent]
})
export class ComponentsModule {}
由於opty.module.ts顯式導入OptyHeaderComponent以及dec因此我無法理解如何解決這個問題。
你有'components.module.ts',所以只需將它導入到你的'opty.module.ts'。不要再導入組件。 – Duannx
不知道如何將模塊導入到另一個模塊。請舉個例子 – Vik
看我的[回覆](https://stackoverflow.com/a/46166922/4254681)。如果仍然面臨錯誤,請讓我知道 – Duannx