Angular url adds unwanted characters

I had a project where the url just worked fine when working locally by going to

localhost: 9000 /

Url will become

http: // localhost: 9000 / # /

For some changes, I did it now to

http: // localhost: 9000 / #! / (with an exclamation mark)

In addition, other URLs are becoming weird. if I try to click a link, for example, go to the toolbar. It does not appeal to me. Instead, it makes the URL as

/ #! / #% 2Fdashboard

and after that nothing happens. What have I done wrong and how can I solve this? I can’t show the code because I don’t know where I was wrong. I completed the following tutorial and after that there was a problem. Perhaps there is a mistake?

tutorial link

I added my .config where I installed the routes.

  .config(function ($routeProvider, $httpProvider) {
$routeProvider
  .when('/', {
    templateUrl: 'views/main.html',
    controller: 'MainCtrl',
    controllerAs: 'vm',
    activetab: 'main'
  })
  .when('/about', {
    templateUrl: 'views/about.html',
    controller: 'AboutCtrl',
    controllerAs: 'vm',
    activetab: 'about'
  })
  .when('/faq', {
    templateUrl: 'views/faq.html',
    controller: 'FaqCtrl',
    controllerAs: 'vm',
    activetab: 'faq'
  })
  .when('/dashboard', {
    templateUrl: 'views/dashboard.html',
    controller: 'DashboardCtrl',
    controllerAs: 'vm',
    activetab: 'dashboard'
  })
  .when('/logout', {
    templateUrl: 'views/main.html',
    controller: 'LogoutCtrl',
    controllerAs: 'vm'
  })
  .otherwise({
    redirectTo: '/'
  });
  $httpProvider.interceptors.push(['$q', '$window', '$localStorage', function($q, $window, $localStorage) {
    return {
      'request': function (config) {
        config.headers = config.headers || {};
        if ($localStorage.globals) {
          config.headers.access_token = $localStorage.globals.currentUser.token;
        }
        return config;
      },
      'responseError': function(response) {
        switch(response.status) {
          case 403:
            //$window.location = '/'
            break;
          case 404:
            //$window.location = './404.html';
            break;
          case 500:
            $window.location = './500.html';
            break;
        }
        return $q.reject(response);
      }
    };
  }]);
+4
3

.

. commit-aa077e8

- , URL- - $location, ('') bang ('!').

-, , :

appModule.config(['$locationProvider', function($locationProvider) {
  $locationProvider.hashPrefix('');
}]);
+9

,

$locationProvider.hashPrefix('');

, 1.6.0 angularjs

+1

, Angular 1.6.0. ​​ , Angular 1.5.9.

0

Source: https://habr.com/ru/post/1663562/


All Articles