0

Why Angular UI router in my simple example encode slashes in url if I mannually trigger state change (with $state.go(toState, toParams)).

$rootScope.$on("$stateChangeStart", function (event, toState, toParams, fromState, fromParams, error) {
            console.log("stateChangeStart");
            $rootScope.loading = true;          
            if(!isLoggedIn) {
                event.preventDefault();
                Api.get().then(function(response){
                    isLoggedIn = response;
                    $state.go(toState, toParams);
                });
            }
        });

Here is full example. http://plnkr.co/1mSXJbN1PMrFiG72oa9m

For example url like: /template1 is encoded to %252Ftemplate1. Otherwise state is also encoded.

This is really weird, how i can disable that?

In $stateChangeStart event I simulate server side user authentication. Another part of this question is how i can treat url /template1 same as /template1/ in this concrete example?

P.S. I shut down html5 mode since it needs a properly configured server (for testing (bug?) in this example html5 mode is required).

Tnx

Vlatko
  • 1,385
  • 1
  • 18
  • 35
  • 1
    See [this question](http://stackoverflow.com/questions/27849260/angular-ui-sref-encode-parameter) and [this comment](https://github.com/angular-ui/ui-router/issues/1119#issuecomment-64696060) – fracz Jan 08 '15 at 22:23
  • 1
    This is solution for url with params, in my example i have no params in any url. Otherwise for 404 is also encoded. – Vlatko Jan 08 '15 at 22:30

0 Answers0