Angular Ionic 3模板解析错误:';添加思想';不是已知元素
我正在使用Ionic v3构建一个应用程序,并创建了一个用于良好实践的自定义组件,以便可以轻松地将其包含在其他页面中 错误如下:Angular Ionic 3模板解析错误:';添加思想';不是已知元素,angular,ionic-framework,ionic3,Angular,Ionic Framework,Ionic3,我正在使用Ionic v3构建一个应用程序,并创建了一个用于良好实践的自定义组件,以便可以轻松地将其包含在其他页面中 错误如下: Template parse errors: 'add-thought' is not a known element: 1. If 'add-thought' is an Angular component, then verify that it is part of this module. 2. If 'add-thought' is a Web Compon
Template parse errors:
'add-thought' is not a known element:
1. If 'add-thought' is an Angular component, then verify that it is part of this module.
2. If 'add-thought' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("
<ion-content padding>
[ERROR ->]<add-thought></add-thought>
<div id="thoughts">
"): ng:///AppModule/ThoughtsPage.html@32:4
src\components\add think\add-think.ts
src\components\add think\add-think.module.ts
我做错了什么?我已根据请求包括自定义元素\u模式
,以抑制消息。我还尝试将生成的components.module.ts
文件全局和本地导入页面。非常感谢您的帮助
编辑:
通过将
CUSTOM\u ELEMENTS\u SCHEMA
添加到app.module.ts
中,我不再看到错误消息,但组件也没有显示。这里有一个StackBlitz:将您的组件添加到应用程序模块
。我完成了你的工作创建stackblitz???@UnluckyAj以下是stackblitz:
<ion-header>
<ion-navbar>
<ion-title>Thoughts</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding>
<add-thought></add-thought>
<div id="thoughts"></div>
</ion-content>
import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { ThoughtsPage } from './thoughts';
import { AddThoughtModule } from '../../components/add-thought/add-thought.module';
@NgModule({
declarations: [
ThoughtsPage,
],
imports: [
IonicPageModule.forChild(ThoughtsPage),
AddThoughtModule
]
})
export class ThoughtsPageModule {}
import { Component } from '@angular/core';
import { ThoughtsProvider } from '../../providers/thoughts/thoughts';
import '../../models/thoughts/thoughts';
@Component({
providers: [ThoughtsProvider],
selector: 'add-thought',
templateUrl: 'add-thought.html'
})
export class AddThoughtComponent {}
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { AddThoughtComponent } from './add-thought';
@NgModule({
declarations: [AddThoughtComponent],
imports: [],
exports: [AddThoughtComponent],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class AddThoughtModule {}