Url loads the characters! #% 2F and does not load the correct view in Angular

0

I'm in my root index.html and it loads normal, but when I type the # plus the / and a view for example the test url view is: strong> index.html #! #% 2Fview-test . I would like to know what!

Follow the route code:

angular.module('teste').config(['$routeProvider', '$locationProvider'], 
    function($routeProvider, $locationProvider){
       $locationProvider.html5Mode(true);
       $routeProvider

       .when('/', {
         templateUrl: 'index.html',
         controller: 'testeCtrl'
       })
       .when('/teste', {
         templateUrl: 'view/teste.html',
         controller: 'testeCtrl'
     });                                                                  
 });
    
asked by anonymous 24.08.2017 / 23:44

1 answer

1

Leandro, when you html5Mode, you disable the use of #, or what we call a friendly url.

To continue using #, you have to remove the $locationProvider.html5Mode(true); line. And to use the friendly url, you need to set the index.html <base href="/"> head and set $locationProvider.html5Mode(true)

Hugs!

    
24.08.2017 / 23:55