【发布时间】:2019-07-23 04:11:43
【问题描述】:
Angular 7.1 , AngularMaterial 7.3
我正在尝试调用函数并传递一些值,它提示以下错误
未找到 t1 的组件工厂。你把它添加到@NgModule.entryComponents 了吗?
虽然t1 包含在entryComponent 中。但是一旦删除传递值以修复值,它将起作用。
<button mat-button (click)="openDialog('t1')">T1</button>
<button mat-button (click)="openDialog('t2')">T2</button>
一旦我传递了值,它就会显示上面的代码。
openDialog(e) {
console.log(e);
const dialogRef = this.dialog.open(e);
dialogRef.afterClosed().subscribe(result => {
console.log(`Dialog result: ${result}`);
dialogRef == null
});
}
@Component({
selector: 't1',
templateUrl: 't1.html',
})
export class t1 {}
@Component({
selector: 't2',
templateUrl: 't2.html',
})
export class t2 {}
但一旦我删除该值并修复 dialogRef.open,它就可以正常工作
const dialogRef = this.dialog.open(t1);
【问题讨论】:
-
如果
t1是您的组件,请将其添加到 appModule 或entryComponents: []数组中的支持模块文件中 -
@Abhishek,
t1,t2已添加到 AppModule 中 -
是否可以分享appModule?
标签: angular dialog angular-material