我有一个左侧的导航in home组件,导航下拉列表在其中一个路由模块(admin-routing.module.ts(中不起作用。导航在应用程序路由模块.ts中工作;路径:"home";组件文件在两个路由模块中是相同的
我是angular的新手,我使用的是angular 14v
我有一个带有";家;
我用了两条路线的
- 应用程序路由模块.ts
- 管理路由模块.ts
这进入应用程序路由模块.ts内部
const routes: Routes =
[
{ path: 'login', component: LoginComponent },
{ path: 'forgot-password', component: ForgotPasswordComponent },
{ path: 'not-found', component: NotFoundComponent },
{ path: '', redirectTo: 'login', pathMatch: 'full' },
{
path: 'admin',
loadChildren: () =>
import('./modules/admin/admin.module').then((m) => m.AdminModule)
},
{path:'home', component:HomeComponent},
{ path: '**', component: NotFoundComponent },
];
这进入管理路由模块.ts内部
const routes: Routes = [
{
path: '',
component: HomeComponent,
children: [
{ path: '', redirectTo: 'dashboard', pathMatch: 'full'},
{ path: 'dashboard', component: DashboardComponent }
]
}
];
我还在angular.json中添加了脚本文件路径
导航下拉菜单和toogle在admin-routing.module.ts的"中不起作用;归属路径";
我在我的服务器中托管了这些文件
工作导航链接是http://angular.byteinnovations.in/home
此导航不起作用http://angular.byteinnovations.in/admin/home
正如我在您的路由中看到的那样
const routes: Routes = [
{
path: '',
component:HomeComponent,
children:
[
{ path: '', redirectTo: 'home', pathMatch: 'full' },
{ path: 'home', component: HomeComponent }
]
}
];
您已经使用HomeComponent两次了,是否可以在adminRouting模块上以这种方式进行检查
const routes: Routes = [
{ path: '', redirectTo: 'home', pathMatch: 'full' },
{ path: 'home', component: HomeComponent }
]