Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

best way to stop scanning when $state.go("aView") #4

Open
nylki opened this issue Jun 27, 2015 · 1 comment
Open

best way to stop scanning when $state.go("aView") #4

nylki opened this issue Jun 27, 2015 · 1 comment

Comments

@nylki
Copy link

nylki commented Jun 27, 2015

I am using the qr-scanner in a ng-view. When switching back with the arrows keys the view gets destroyed and so the qr-scanner stops scanning as expected. (because your module listens for $destroy if I understand the code correctly).

However, in my particular case I am switching the states/views with state.go().
After the view switched, the qr-scanners interval is still running. How can I stop it from doing so?
I could implement a listener into your code, to listen for a certain event to then clear the interval. But i am not sure, it's the cleanest way to go for.

thanks!
(I am an angular newbie, so excuse me if the answer to the problem is rather simple)

@rllola
Copy link

rllola commented Jul 2, 2015

Hi,
You can also broadcast a $destroy event before switching state.
I also needed to stop the scanner with a button click and what I have done i this :

        function stopScan() {
            $scope.$broadcast('$destroy');
        }

Not sure this is the cleanest way to do but I does the job.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants