angular 个链接的问题
Issues with angular links
你好,我遇到了 angular 的问题,我不知道如何解决,
<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"});
});
}());
但是任何时候我点击 link 显示的 url 都是 http://localhost/plunk/#!/main#%2Fuser%2Fangular, for some reasons the "/" is replaced with "%2F" and the url that is loaded is the otherwise url, but if I do, http://localhost/plunk/#!/user/angular 它工作正常,请问我该如何解决这个问题
通常,%2F 是正斜杠/character.Inorder 的百分比编码,用于修复配置中的 。
你可以,
git.config(['$locationProvider','$routeProvider', function($locationProvider,$routeProvider) {
$locationProvider.hashPrefix('');
}]);
你好,我遇到了 angular 的问题,我不知道如何解决,
<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"});
});
}());
但是任何时候我点击 link 显示的 url 都是 http://localhost/plunk/#!/main#%2Fuser%2Fangular, for some reasons the "/" is replaced with "%2F" and the url that is loaded is the otherwise url, but if I do, http://localhost/plunk/#!/user/angular 它工作正常,请问我该如何解决这个问题
通常,%2F 是正斜杠/character.Inorder 的百分比编码,用于修复配置中的
你可以,
git.config(['$locationProvider','$routeProvider', function($locationProvider,$routeProvider) {
$locationProvider.hashPrefix('');
}]);