我正在尝试在退出的Ionic应用程序中添加标签:
目录结构:
- src/pages/admin/dashboard
- src/pages/admin/tabs
- ..../tabs/ tabs.module.ts , tabs.page.html , tabes.page.ts , tabs.router.module.ts
tabs.module.ts代码:
import { DashboardPage } from '../dashboard/dashboard.page';
@NgModule({
imports: [
IonicModule,
CommonModule,
FormsModule,
TabsPageRoutingModule,
DashboardPage
],
declarations: [TabsPage]
})
export class TabsPageModule {}
tabs.router.module.ts代码:
const routes: Routes = [
{
path: 'tabs',
component: TabsPage,
children: [
{
path: 'dashboard',
outlet: 'dashboard',
loadChildren: '../dashboard/dashboard.module#DashboardPageModule'
}
]
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class TabsPageRoutingModule {}
根据错误消息尝试所有来源对谷歌进行更改 但仍然停留在以下错误消息中:
core.js:12501 ERROR Error: Uncaught (in promise): Error: Unexpected directive 'DashboardPage' imported by the module 'TabsPageModule'. Please add a @NgModule annotation.
Error: Unexpected directive 'DashboardPage' imported by the module 'TabsPageModule'. Please add a @NgModule annotation.
感谢任何帮助或提示
答案 0 :(得分:0)
您的问题出在您的错误代码中:
Unexpected directive 'DashboardPage' imported by the module 'TabsPageModule'.
在 tabs.module.ts 中,您需要导入PageModule而不是页面本身。
因此,将 DashboardPage 更改为 DashboardPageModule 。