grbsk / ng-idle

Responding to idle users in AngularJS applications.
http://hackedbychinese.github.io/ng-idle
MIT License
564 stars 195 forks source link

Setting timeout with variable data #200

Open alexandroscgb opened 7 years ago

alexandroscgb commented 7 years ago

Hi. I'm trying to set the timeout with a value that should come from a function in $scope, but in that momento of the app loading, nothing like $scope of anything else exists yet. How could I do this? Is it even possible?

Thanks.

adamfollett commented 7 years ago

Having the exact same issue. I need to pull the idle and timeout data from an external service depending on the client logged in. Any help on this would be great!

mberrang commented 7 years ago

@alexandroscgb @adamfollett - Correct, you can't do this on config while angular is bootstrapping itself (you can only manually set the values in config and only providers can be injected into a configuration block)

However, after initial config, you should be able to use setTimeout() or setIdle() on the Idle service. You should be able to do that in any service, controller, or factory (e.g., immediately on/after login) that needs access to $scope (I would recommend a service).

See: https://github.com/HackedByChinese/ng-idle/issues/206#issuecomment-315958885