英文:
Unable to use reactive forms in Ionic Angular 7 project due to missing app.module.ts file
问题
我正在开发一个 Ionic Angular 7 项目,尝试在我的应用程序中使用响应式表单。由于 Ionic Angular 7 中移除了 app.module.ts,我尝试查阅了一些在互联网上找到的文章。然而,当我尝试在我的 main.ts 文件中导入 ReactiveFormsModule,就像那些文章中提到的那样,它并没有起作用。
在导入了 ReactiveFormsModule 后 main.ts 文件中的代码示例:
bootstrapApplication(AppComponent, {
providers: [
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy },
importProvidersFrom(IonicModule.forRoot({}),ReactiveFormsModule),
provideRouter(routes),
],
});
我不确定如何在我的 Ionic Angular 7 项目中继续使用响应式表单。我应该如何将 ReactiveFormsModule 添加到我的项目中并使用响应式表单?
英文:
I'm working on an Ionic Angular 7 project and I'm trying to use reactive forms in my application. As app.module.ts is removed from Ionic Angular 7, I tried to check through few articles found on Internet. However, when I try to import the ReactiveFormsModule in my main.ts file as mentioned in those articles, it didn't work.
Sample of code from main.ts after importing ReactiveFormsModule:
bootstrapApplication(AppComponent, {
providers: [
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy },
importProvidersFrom(IonicModule.forRoot({}),ReactiveFormsModule),
provideRouter(routes),
],
});
I'm not sure how to proceed with using reactive forms in my Ionic Angular 7 project. How can I add the ReactiveFormsModule to my project and use reactive forms?
答案1
得分: 1
在使用该组件时,您需要在其中导入它:
@Component({
standalone:true,
imports: [ReactiveFormsModule]
})
英文:
You need to import it in the component it's being used in:
@Component({
standalone:true,
imports: [ReactiveFormsModule]
})
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论