我建立一个AngularJS参加办法,我有建设第二视图时URL问题:AngularJS:路线提供商转变“/”到%2F
我appContact.js看起来是这样的:
(function() {
"use strict";
var app = angular.module("appContacts", ["simpleControls", "ngRoute"])
.config(function ($routeProvider, $locationProvider) {
$routeProvider.when("/", {
controller: "contactsController",
controllerAs: "vm",
templateUrl: "/views/contactsView.html"
});
$routeProvider.when("/details/:firstName", {
controller: "contactsDetailsController",
controllerAs: "vm",
templateUrl: "/views/detailsView.html"
});
$routeProvider.otherwise({ redirectTo: "/"});
$locationProvider.html5Mode({
enabled: true,
requireBase: false
});
});
})();
在我的HTML我有此链接:
<a asp-controller="Contact" asp-action="Details" ng-href="#/details/{{contact.firstName}}" >{{ contact.firstName}}</a>
当我在浏览器悬停我有这样的建议正确链接:
**http://localhost:8000/#/details/Matthew**
但是,当我点击链接的URL变化导航到新页面
**http://localhost:8000/#%2Fdetails%2FMatthew**
更改“/”%2使应用程序失败,一个空白页所示。
你知道这是为什么吗?如何解决这个问题?
我已经阅读过类似的文章她,但他们都没有似乎工作,因为我没有访问编码的URL之前,它到达浏览器,并出现错误。
感谢
拉斐尔
你读过这http://stackoverflow.com/questions/24814472/angularjs - 转化 - 我-NG-HREF的URL斜杠为-2F? – MMhunter
它将与散列工作 –
@MMhunter:是的,我读了它,我在我的解决方案尝试它,但它没有奏效。 –