2017-04-01 59 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(''); 
}]);