H
H
hobu4ok912016-09-28 05:16:48
Angular
hobu4ok91, 2016-09-28 05:16:48

Why is the $stateChangeStart event not working?

I use webpack. The code is like this:

// main app
var app = angular.module('app', [
    'ui.router',
    'ngCookies',
    'app.auth',
    'app.advert',
    'app.encyclopedia',
    'app.post'
]);
app.run(function ($rootScope) {
    $rootScope.$on('$stateChangeStart',
        function(event, toState, toParams){
            event.preventDefault();
            console.log(123);
        })
});

Other events work, I tried it, but it doesn't want to

Answer the question

In order to leave comments, you need to log in

2 answer(s)
H
hobu4ok91, 2016-09-28
@hobu4ok91

But because $stateChangeStart is deprecated, and you need to use $transitionts

N
Nicholas, 2016-09-28
@healqq

If you are using the 1.0 version - as suggested - you should use $transitions . If 0.2.x - then everything should be OK.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question