DisplayAreaComponent
我有一个 Angular2 项目,它在屏幕上有 2 个组件 ( ) 实例。我希望每个DisplayAreaComponent
实例都有自己的Idle
实例(根据README是允许的),所以我Idle
在组件构造函数中注入,然后EventTargetInterruptSource
用于中断源。但是,中断源没有响应我的鼠标点击,这让我觉得我设置不正确。
应用模块:
...
imports: [
BrowserModule,
FormsModule,
HttpModule,
NgIdleModule.forRoot()
],
...
DisplayAreaComponent 构造函数:
constructor(
private element: ElementRef,
private idle: Idle
)
{
// give the idle instance a unique name
idle.setIdleName("display-area-" + this.displayId);
// sets an idle timeout of 5 seconds, for testing purposes.
idle.setIdle(5);
// clears the timeout
idle.setTimeout(0);
// sets the interrupts for this component, in this case, things like clicks, scrolls, touches to the document
idle.setInterrupts([new EventTargetInterruptSource(this.element.nativeElement, "mousedown touchstart")]);
idle.onIdleStart.subscribe(() => this.idleStartHandler());
idle.onIdleEnd.subscribe(() => this.idleEndHandler());
任何想法我做错了什么?