Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

angular routing adding unwanted hash tags to URL #3083

@jssebastian

Description

@jssebastian

When using angular routing with a "/" route, an unwanted hash tag is added to the URL by angular. I cannot demonstrate this in a plunkr/jsfiddle, but if you put the page below on a server as test.html, and try to visit myserver.com/test.html, you get redirected to myserver.com/test.html#/test.html, and the page says "Hello test.html". Visiting test.html#/ works as expected and displays "Hello Dude".

Switching the link to angular 1.1.4 fixes the problem.

<html dir="ltr" lang="en-US">

<head>
  <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.1.5/angular.js"></script>
  <script>
    angular.module('testPage',[])
      .controller('testCtrl',function($scope,$routeParams){
        $scope.name="Dude";
        if($routeParams.name){
          $scope.name=$routeParams.name;
        }
      })
      .config(function($routeProvider){
        $routeProvider
          .when('/:name',{
            template: '<div>Hello {{name}}</div>',
            controller: "testCtrl"
          })
          .when('/',{
            template: '<div>Hello {{name}}</div>',
            controller: "testCtrl"})
          .otherwise({
            template: 'No route!'
          });

      });
  </script>

</head>
<body ng-app="testPage">
  <div ng-view>
  </div>
</body>


</html>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions