Angularjs 为什么我的路由在Angular JS for URL中不起作用?

Angularjs 为什么我的路由在Angular JS for URL中不起作用?,angularjs,Angularjs,我使用下一个配置进行路由: .config(['$routeProvider', function($routeProvider) { $routeProvider .when('/appointments', { controller: 'AppointmentController' }) }]) 和控

我使用下一个配置进行路由:

.config(['$routeProvider',
            function($routeProvider) {
                $routeProvider
                    .when('/appointments', {
                        controller: 'AppointmentController'
                    })
    }])
和控制器:

.controller('AppointmentController', ['$scope', '$http', '$sce', function ($scope, $http, $sce) {
     alert('Test')
}]);
Url看起来像:
http://blogapp.com/appointments

所以,我在页面上没有错误,但是当我输入URL时,
alert()
不起作用

http://blogapp.com/#/appointments

默认情况下,Angular将包含哈希。

正如Arthur所评论的,您需要转到
http://blogapp.com/#/appointments

要停止此操作并删除#,请将配置替换为:

.config(['$routeProvider', '$locationProvider',
            function($routeProvider, $locationProvider) {
                $routeProvider
                    .when('/appointments', {
                        controller: 'AppointmentController'
                    })

$locationProvider.html5Mode(true);

    }])

尝试使用
http://blogapp.com/appointments
(结尾有一个“s”)对不起,有一个打字错误。我有
s
的URL不能,因为我有关于/appointments的PHP页面,我喜欢你提供的,那么PHP的其他URL将不起作用