【发布时间】:2018-02-25 05:09:18
【问题描述】:
我使用 ionic start 生成了一个空白应用程序。那运行良好。
现在我添加了一个名为 opty 的新页面 ionic g page opty。
单击按钮时使用 navPush 从 home.html 到 opty.html 创建导航。效果很好。
现在,我添加了一个组件,使用: ionic g 组件 opty-header
到这里为止一切都很好。现在,如果将其包含在 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/OptyPage.html@16: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 并声明,所以我无法理解如何修复它。
【问题讨论】:
标签: angular typescript ionic2 ionic3