Angular Mat表重定向到根目录
我有一个基于Angular Mat表重定向到根目录,angular,angular-material,Angular,Angular Material,我有一个基于angular v6的项目,问题是每当我尝试在任何组件中使用mat table时,该组件只会重定向到root,而开发者工具控制台中没有错误 当我点击车辆临时路径时,它会将我重定向到根页面,虽然代码中似乎没有任何错误,但我无法找出问题所在 这是我的组件 我的模块 import { MatTableModule } from '@angular/material'; import { RouterModule, Routes } from '@angular/router'; impor
angular v6
的项目,问题是每当我尝试在任何组件中使用mat table时,该组件只会重定向到root,而开发者工具控制台中没有错误
当我点击车辆临时路径时,它会将我重定向到根页面,虽然代码中似乎没有任何错误,但我无法找出问题所在
这是我的组件
我的模块
import { MatTableModule } from '@angular/material';
import { RouterModule, Routes } from '@angular/router';
import { BrowserModule } from '@angular/platform-browser';
const routes: Routes = [{path: 'vehicles-temp', component: VehicleHistoryDetailsDialogComponent}];
@NgModule({
imports: [
RouterModule.forChild(routes),
BrowserModule,
MatTableModule
],
declarations: [
VehicleHistoryDetailsDialogComponent
],
exports: [
VehicleHistoryDetailsDialogComponent
],
})
export class VehicleHistoryModule {}
我的模板
<table mat-table [dataSource]="[]">
<ng-container matColumnDef="operation_name">
<th mat-header-cell *matHeaderCellDef>Operation</th>
<td mat-cell *matCellDef="let row">{{row.operation_name}}</td>
</ng-container>
<ng-container matColumnDef="ro_number">
<th mat-header-cell *matHeaderCellDef>RO #</th>
<td mat-cell *matCellDef="let row">{{row.ro_number}}</td>
</ng-container>
<ng-container matColumnDef="repair_shop_location">
<th mat-header-cell *matHeaderCellDef>Location</th>
<td mat-cell *matCellDef="let row">{{row.repair_shop_location}}</td>
</ng-container>
<ng-container matColumnDef="status">
<th mat-header-cell *matHeaderCellDef>Status</th>
<td mat-cell *matCellDef="let row">{{row.status}}</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"
更新:如果对重定向停止的表进行注释我已经弄清楚了,问题出在我使用的tsconfig中的
“target”:“es2016”
。将其切换到es5
它再次开始工作。请显示您的路由器配置和使用mat表的组件。我已经用代码更新了问题。这只是路由器配置的一部分,组件类也很有帮助。组件为空,只是添加了@component Decorator根路由器模块也是
`
const appRoutes: Routes = [
{path: 'login', component: LoginComponent},
{path: 'login/:profile_id', component: AuthLoginComponent},
{path: 'signup', component: SignUpComponent},
{path: 'reset-password', component: ResetPasswordComponent},
{path: 'reset-password/:token', component: ResetPasswordComponent},
{path: 'inventory', component: InventoryListComponent, canActivate: [UserService], data: {id: 'inventory_enabled'}},
{path: 'dashboard', component: DashboardComponent, canActivate: [UserService], data: {id: 'dashboard_enabled'}},
{path: '', redirectTo: 'ros', pathMatch: 'full'},
{path: '**', component: NotFoundComponent}
];
@NgModule({
imports: [
RouterModule.forRoot(appRoutes)
],
exports: [
RouterModule
]
})
`