【发布时间】:2023-07-02 05:56:01
【问题描述】:
我正在尝试在 ionic5 中创建服务并在特定页面中使用它,因此我将其导入 app.module.ts 以及 page.module.ts 文件中
我面临的问题是
core.js:6498 ERROR 错误:未捕获(承诺中):错误:类型 MiscService 没有 'ɵmod' 属性。错误:键入 MiscService 没有 'ɵmod' 属性。 在 getNgModuleDef (core.js:1131)
这是我的页面模块
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { IonicModule } from '@ionic/angular';
import { FormsModule } from '@angular/forms';
import { HomePage } from './home.page';
import { HomePageRoutingModule } from './home-routing.module';
import { TranslateModule } from '@ngx-translate/core';
import { MiscService } from '../../providers/misc.service';
@NgModule({
imports: [
CommonModule,
FormsModule,
IonicModule,
HomePageRoutingModule,
TranslateModule,
MiscService
],
declarations: [HomePage],
exports:[TranslateModule]
})
export class HomePageModule { }
【问题讨论】:
-
请发布附加代码。例如 MiscService 文件。没有足够的信息来回答这个问题。
-
您在
providers数组中设置服务或在providedIn中声明模块在@Injectable中键入开始。 angular.io/guide/providers#providedin-and-ngmodules 不在导入中 -
@E.Maggini 我认为这只是一个导入问题......
-
@SurajRao 没有更多细节,我们只能猜测。 :)
标签: angular ionic-framework ionic5