Closed sublime392 closed 7 years ago
I got it working following an answer in another issue here.
I made an idle.hack.ts
file with
import { Injectable } from '@angular/core';
import { Idle, SimpleExpiry } from 'ng2-idle/core';
@Injectable()
export class PalIdle extends Idle {
constructor(expiry: SimpleExpiry) {
super(expiry, undefined);
}
}
and then in my app.module
import { SimpleExpiry, IdleExpiry } from 'ng2-idle/core';
import { PalIdle } from './idle.hack';
...
providers: [
PalIdle,
SimpleExpiry,
{ provide: IdleExpiry, useExisting: SimpleExpiry },
],
...
and finally injecting the new class where needed
constructor(
private idle: PalIdle,
) {}
I also had difficulty with the "Optional" Keepalive provider.
export const ALL_IDLE_PROVIDERS = [
LocalExpiry,
{provide: IdleExpiry, useExisting: LocalExpiry},
// The following hack is required to avoid DI errors
{provide: KeepaliveSvc, useValue: undefined},
Idle
];
Maybe the JS in the current release is compiled incorrectly?
I am having the same issue but the fix above is not working for me. I am getting 'SimpleExpiry' is not exported by node_modules\ng2-idle\core.js (imported by app\app.module.js)' I should mention that I am getting this error while executing rollup so I am facing this issue at another point in my build process.
@mdsauer can you try import { SimpleExpiry } from 'ng2-idle/simpleexpiry';
@Tiuser4567 That worked! I changed my idle.hack.ts to:
import { Injectable } from '@angular/core';
import { Idle } from 'ng2-idle/idle';
import { SimpleExpiry } from 'ng2-idle/simpleexpiry';
@Injectable()
export class PalIdle extends Idle {
constructor(expiry: SimpleExpiry) {
super(expiry, undefined);
}
}
I made similar changes to my app.module.ts:
import { SimpleExpiry } from 'ng2-idle/simpleexpiry';
import { IdleExpiry } from 'ng2-idle/idleexpiry';
I then also added ng2-idle to the commonjs rollup plugin:
include: [
'node_modules/rxjs/**',
'node_modules/angular-in-memory-web-api/**',
'node_modules/ng2-idle/**'
],
Thanks for the help!
@dasis You are able to do the AOT compile? I am still getting Error: Error at .../aot/app/app.module.ngfactory.ts:72:32: Module '".../node_modules/ng2-idle/core"' has no exported member 'IDLE_PROVIDERS'.
Are you doing anything special regarding ng2-idle in you systemjs.config.js or anywhere else?
@dasis can you answer that question
http://www.codeproject.com/Questions/1148292/Angular-idel-user-state
Hi this works fine in dev mode and regular peoduction mode but AoT does not compile. It gives
node_modules/ng2-idle/core"' has no exported member 'IDLE_PROVIDERS'.
andnode_modules/ng2-idle-keepalive/core"' has no exported member 'KEEPALIVE_PROVIDERS'
This is with angular 2.1.0