Angular 离子模态:未找到任何组件工厂
我想在爱奥尼亚打开一个模态:Angular 离子模态:未找到任何组件工厂,angular,ionic-framework,ionic4,Angular,Ionic Framework,Ionic4,我想在爱奥尼亚打开一个模态: export class TexteditorComponent { function showFormulaEditor() { this.modalCtrl.create({ component: FormulaCreatorComponent }).then(m => m.present()); } } 但是,当执行此代码时,我得到以下错误: Error: "Uncaught (in promise): E
export class TexteditorComponent {
function showFormulaEditor() {
this.modalCtrl.create({
component: FormulaCreatorComponent
}).then(m => m.present());
}
}
但是,当执行此代码时,我得到以下错误:
Error: "Uncaught (in promise): Error: No component factory found for FormulaCreatorComponent. Did you add it to @NgModule.entryComponents?
TexteditorComponent和FormulaCreatorComponent在texteditor.module.ts中注册:
@NgModule({
declarations: [TexteditorComponent, FormulaCreatorComponent],
entryComponents: [TexteditorComponent, FormulaCreatorComponent],
imports: [
CommonModule
],
exports: [TexteditorComponent, FormulaCreatorComponent]
})
export class TexteditorModule { }
@NgModule({
imports: [
CommonModule,
FormsModule,
IonicModule,
TexteditorModule,
RouterModule.forChild(routes)
],
declarations: [ExercisePage, PatternedInputComponent]
})
export class ExercisePageModule {
constructor() {
console.log("ExercisePageModule init");
}
}
texteditor.module.ts在exercise.module.ts中导入:
@NgModule({
declarations: [TexteditorComponent, FormulaCreatorComponent],
entryComponents: [TexteditorComponent, FormulaCreatorComponent],
imports: [
CommonModule
],
exports: [TexteditorComponent, FormulaCreatorComponent]
})
export class TexteditorModule { }
@NgModule({
imports: [
CommonModule,
FormsModule,
IonicModule,
TexteditorModule,
RouterModule.forChild(routes)
],
declarations: [ExercisePage, PatternedInputComponent]
})
export class ExercisePageModule {
constructor() {
console.log("ExercisePageModule init");
}
}
“练习”页面使用其选择器加载TextEditor组件:
<app-texteditor [(ngModel)]="exercise.Exercise"></app-texteditor>
<app-formulacreator></app-formulacreator>
尽管如此,我可以使用其选择器将FormulaCreatorComponent添加到TexteditorComponent:
<app-texteditor [(ngModel)]="exercise.Exercise"></app-texteditor>
<app-formulacreator></app-formulacreator>
那没问题。我终于解决了。。。
在texteditor.component.ts中,我导入了FormulaCreatorComponent,其行如下:
import { FormulaCreatorComponent } from './formulacreator/formulacreator.component.js';
显然,.js
是不正确的。我的IDE(Visual Studio代码)无论如何都能识别它,并在单击“打开定义”时将我引导到正确的目的地。我最终解决了它。。。
在texteditor.component.ts中,我导入了FormulaCreatorComponent,其行如下:
import { FormulaCreatorComponent } from './formulacreator/formulacreator.component.js';
显然,
.js
是不正确的。我的IDE(Visual Studio代码)无论如何都能识别它,并在我单击“打开定义”时引导我找到了正确的目标。将FormulaCreatorComponent
添加到exports
ArrayTanks,但我在将FormulaCreatorComponent添加到exports时遇到了相同的错误。我只在TexteditorComponent中使用该组件,该组件在同一模块中注册。您在app.module.ts
no?no中导入了TextEditorModule
,我将app.module添加到问题add textededitormodule to imports app.module.ts数组错误将被解决,并将FormulaCreatorComponent
添加到exports
arrayThanks,但我在将FormulaCreatorComponent添加到exports时得到相同的错误。我只在TexteditorComponent中使用该组件,该组件在同一模块中注册。您在app.module.ts
no中导入了TextEditorModule
?否,我将app.module添加到问题中add TextEditorModule to imports数组中的app.module.ts错误将得到解决