AngularJS refesh显示空白页面

时间:2016-05-22 18:36:27

标签: html angularjs routing refresh

我有一个AngularJS项目,当我点击gamesList页面内的刷新时,我会看到一个空白页面。

这是我的app.js:

var app = angular.module("app",['ngRoute','superCtrl']);

app.config(routeConnect);

function routeConnect($routeProvider,$locationProvider){

    $locationProvider.html5Mode({
        enabled: true,
        requireBase: false
    });

$routeProvider
    .when('/',{
        templateUrl:'/App/templates/home.html',
        controller:'navCtrl'
     })
    .when('/gamesList', {
        templateUrl:'/App/templates/gamesList.html',
        controller:'gamesListCtrl'
    }));
}

我使用http-server运行应用程序,当我点击日志中的刷新按钮时,我得到:

"Get /gamesList" Error(404):"Not Found"

此外,我注意到在chrome开发人员中,源代码发生了变化:

在:

enter image description here

后:

enter image description here

对这个问题有任何想法吗?

2 个答案:

答案 0 :(得分:1)

如果您不知道导致此问题的原因,只需从app.js中的.config中删除$ locationProvider ...

我删除了$ locationProvider,所以问题就消失了,但我必须使用

`http://localhost:8080/#/home

但是'#'出现在网址中......

答案 1 :(得分:-2)