2017-04-01 56 views
2

你好,我是有角这个问题,我不知道如何解决它,问题与角链接

<td><a href="#!/repo/{{searchValue}}/{{repo.name}}">{{repo.name}}</a></td> 

我有这个在我看来,并在此定义

(function(){ 
    var git = angular.module("main", ["ngRoute"]); 
    git.config(function($routeProvider){ 
    $routeProvider 
    .when("/main", { 
     templateUrl: "main.html", 
     controller: "MainCtrl" 
     }) 
     .when("/user/:username", { 
     templateUrl: "user.html", 
     controller: "userController" 
     }) 
     .when("/repo/:username/:reponame", { 
     templateUrl: "repo.html", 
     controller: "repoController" 
     }) 
     .otherwise({redirectTo: "/main"}); 
    }); 
}()); 
路线

但任何时候我按照点击链接显示的网址是http://localhost/plunk/#!/main#%2Fuser%2Fangular,由于某些原因,“/”被替换为“%2F”,并加载的URL是否是其他网址,但如果我这样做,http://localhost/plunk/#!/user/angular它工作正常,请问我该如何解决这个问题

回答

1

通常,%2F是正斜杠/字符的百分比编码。在您的配置中订购包括$locationProvider.hashPrefix('');

你可以做,

git.config(['$locationProvider','$routeProvider', function($locationProvider,$routeProvider) { 
    $locationProvider.hashPrefix(''); 
}]);