如果从地址网址中删除#,我尝试在路由器中使用$ location provider。在第一次加载时将root更改为另一个url工作。但当我重新加载新页面时,我自己得到Cannot GET /functionalists
这是我的配置:
app.config(['$routeProvider','$locationProvider' ,
function ($routeProvider , $locationProvider ) {
$routeProvider.
when('/functionalists',
{
templateUrl: '/public/app/views/functionalities/functionalities.html',
controller: 'FuntionalitiesController'
})
.when('/setting',
{
templateUrl: '/public/app/views/setting/setting.html',
controller: 'SettingController'
})
.when('/guide',
{
templateUrl: '/public/app/views/guide/guide.html',
controller: 'GuideController'
})
.when('/contact',
{
templateUrl: '/public/app/views/contactus/contactus.html',
controller: ''
})
.when('/token',{
})
.otherwise({
redirectTo: '/'
});
$locationProvider.html5Mode(true);
}]);
这是我用于重定向的控制器
app.controller('MainViewController', ['$scope', '$location', 'MainViewFactory', function ($scope, $location, MainViewFactory) {
$scope.functions = function () {
$location.path("/functionalists")
};
$scope.setting = function () {
$location.path("/setting")
};
$scope.guide = function () {
$location.path("/guide")
};
$scope.contactUs = function () {
$location.path("/contact")
};
}]);
请在这个问题上帮助我!
答案 0 :(得分:0)
您应该在服务器端处理此问题(后端) 实际上,请求http://server.net/setting以这种方式将您带到网络服务器,而您的网络服务器没有正确回复您,
在appache和php索引页面我使用类似这样的东西:
Header add Access-Control-Allow-Origin "http://localhost:3000"
Header add Access-Control-Allow-Credentials "true"
Header add Access-Control-Allow-Headers "origin, x-requested-with, content-type"
Header add Access-Control-Allow-Methods "GET, POST"
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
<FilesMatch "\.php$">
Order Allow,Deny
Deny from all
</FilesMatch>
<FilesMatch "index[0-9]?\.php$">
Order Allow,Deny
Allow from all
</FilesMatch>
如果你的后端没有访问权限,那么你应该使用主题标签