对于一个小项目,我遇到Angular CLI: 1.7.4
和Node: 9.11.1
的奇怪行为。主要问题是应用程序在双击时显示两个不同的页面(概述+详细信息),但对于contextmenu>单击它按预期工作(仅显示详细信息),尽管它们使用相同的方法进行重定向。
图像显示预期的DOM(=适用于contextmenu> click)和双击的实际结果:
app-routing.module.ts
:(我的主要路由文件)
const routes: Routes = [
{ path: 'overview', component: OverviewComponent, canActivate: [AuthGuardService], data: { title: 'Produktionskette' } },
{ path: 'options', component: OptionComponent, canActivate: [AuthGuardService], data: { title: 'Optionen' } },
{ path: 'login', component: LoginComponent, data: { title: 'Anmelden' } },
{ path: 'details/:id', component: DetailComponent, canActivate: [AuthGuardService], data: { title: 'Details' } },
{ path: '', redirectTo: '/overview', pathMatch: 'full' },
{ path: '**', redirectTo: '/overview' }
];
@NgModule({
exports: [ RouterModule ],
imports: [ RouterModule.forRoot(routes) ]
})
export class AppRoutingModule { }
组件非常基础,并与jQuery一起与vanilla-JS交互。在图表中,上下文菜单初始化为:
context.find(".contextView").click(event => {
event.preventDefault();
context.hide();
if (selectedDevice) {
showDeviceDetails(selectedDevice);
}
});
在每个设备内(每个设备)初始化双击:
object.dblclick(() => diagram.showDeviceDetails(_this));
Angular 2组件定义如下:
overview.component.ts
:( / overview)
@Component({
selector: 'app-overview',
templateUrl: './overview.component.html',
styleUrls: ['./overview.component.css']
})
export class OverviewComponent implements OnInit {
// does not do very much, just loading etc
}
detail.component.ts
:(详情/:id)
Component({
selector: 'app-detail',
templateUrl: './detail.component.html',
styleUrls: ['./detail.component.css']
})
export class DetailComponent implements OnInit {
// also works as intended
}
这可能是路由问题吗?如上所述,doubleclick和contextmenu> click使用相同的方法,两种执行类型都在detail-component内部工作。