Sub*_*ham 5 typescript angular-ui-router angular
我正在尝试创建一个 Angular 对话框。为此,我将一个组件导入到 Service 类中,但出现以下错误。我正在使用不同的模块并在该模块上添加了一个入口组件
错误:未找到 NewPasswordComponent 的组件工厂。你把它添加到@NgModule.entryComponents 了吗?
新密码/新密码.module.ts
import { NewPasswordRoutingModule } from './newpassword-
routing.module';
import { NewPasswordComponent } from './newpassword.component';
export * from './newpassword.component';
@NgModule({
imports: [
CommonModule,
NewPasswordRoutingModule
FlexLayoutModule.withConfig({addFlexToParent: false})
],
exports: [
NewPasswordComponent
],
declarations: [NewPasswordComponent],
entryComponents: [NewPasswordComponent],
})
export class NewPasswordModule {}
Run Code Online (Sandbox Code Playgroud)
app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import {AppRoutingModule} from "./app-routing.module";
import { AppComponent } from './app.component';
import {SomeService} from "./shared/someservice.service";
@NgModule({
declarations: [
AppComponent,
],
imports: [
BrowserModule,
AppRoutingModule,
],
providers: [SomeService],
bootstrap: [AppComponent]
})
export class AppModule { }
Run Code Online (Sandbox Code Playgroud)
共享/someservice.service.ts
import {MatDialog, MatDialogRef, MAT_DIALOG_DATA,MatDialogConfig} from
'@angular/material/dialog';
import { NewPasswordComponent } from
'../newPassword/newpassword.component';
@Injectable()
export class SomeService {
constructor(public dialog: MatDialog) {
}
LogIn(){
let dialogRef: MatDialogRef<NewPasswordComponent>;
const config = new MatDialogConfig();;
config.role = 'dialog';
config.width = '60%';
config.data = { newpassword: that.newpassword };
dialogRef = that.dialog.open(NewPasswordComponent, config);
console.log("Dialog Start"+email);
dialogRef.afterClosed().subscribe(result => {
that.newpassword = result;
console.log("Dialog closed"+result);
});
}
}
Run Code Online (Sandbox Code Playgroud)
我收到以下错误。我在密码模块中添加了入口组件,但仍然收到此错误
错误:未找到 NewPasswordComponent 的组件工厂。你把它添加到@NgModule.entryComponents 了吗?
| 归档时间: |
|
| 查看次数: |
1535 次 |
| 最近记录: |