M
M
Maxim2017-09-28 15:10:26
JavaScript
Maxim, 2017-09-28 15:10:26

How to find out which route the user is in?

I use ui-router, when switching between routes, I need to catch where the user is now.
Found function

$rootScope.$on('$stateChangeSuccess',
                function (event, toState, toParams, fromState, fromParams){
                    // console.log(fromState.url);
                    // console.log(toState.url);
                }
            );

Displays the current position of the user and everything seems to be ok, but you need to make the whole thing callable,
I tried to wrap the whole thing in a function, but crap, I can’t get data from the internal $rootScope function.
Also, declaring a variable global and redefining it does not work, it is not redefined.
What are the possible solutions, is it really so difficult to get the user's current route?
There are analogues for location.path, etc. ?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim, 2017-09-28
@maximkv25

$rootScope.$on('$locationChangeStart', function() {
                leftButtonTranslate();

            });

O
oh, 2017-09-28
well @AnneSmith

get yourself a simple json and write there all the information that you need, when it happens
and in general it’s far from the fact that you set the task correctly, which is probably why you don’t see a solution

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question