Angularjs 在HTML5模式下(true),视图不会在angular js的页面刷新中加载

Angularjs 在HTML5模式下(true),视图不会在angular js的页面刷新中加载,angularjs,Angularjs,使用html5mode(true)时,angular.js中的页面刷新时不会加载视图 <base href="/"> <div ng-app="directives" > <a href="/home">Home</a> <a href="/about">about</a> <a href="/contact">contact</a>

使用html5mode(true)时,angular.js中的页面刷新时不会加载视图

    <base href="/">
    <div ng-app="directives" >
        <a href="/home">Home</a>
        <a href="/about">about</a>
        <a href="/contact">contact</a>
        <div ng-view></div>
    </div>


未呈现正确的视图。

这是使用
HTML5模式(true)
的缺点之一

基本上,您的服务器找不到资源,因为该URL下没有资源。地址由Angular控制,而且Angular还没有开始控制页面、URL等内容


我发现这个问题的解决方案是在我的Apache服务器上设置一个URL重写()来清理URL并删除
html5Mode(true)

这可能是您的服务器处理/about的路由时出现的问题。你用的是什么服务器?
    directives.config(["$routeProvider","$locationProvider",function($routeProvider,$locationProvider){
    $routeProvider.when("/",{
        templateUrl:"directives/home.html"
    }).when("/home",{
        templateUrl:"directives/about.html"
    }).when("/about",{
        templateUrl:"directives/contact.html"
    }).when("/contact",{
        templateUrl:"directives/about.html"
    }).otherwise({
        redirectTo : "/"
    })
    $locationProvider.html5Mode(true).hashPrefix("!")
}])