Angular漂亮的网址无法正常工作并导致控制台错误

时间:2017-10-30 17:45:05

标签: jquery angularjs

我试图构建我的第一个角度应用程序只有html5mode网址不起作用?

    var app = angular.module('vennDigital', ['ngRoute', 'ngAnimate']);

    app.config(['$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider) {


        $routeProvider
        .when("/", {
            templateUrl: "partials/home.html", 
            controller: "HomeCtrl"
            }
        )
        .when("/about", {
            templateUrl: "partials/about.html", 
            controller: "AboutCtrl"
            }
        )
        .when("/services", {
             templateUrl: "partials/services.html", 
             controller: "ServiceCtrl"
             }
        );

     // use the HTML5 History API
            $locationProvider.html5Mode(true);


    }]);


    app.controller('HomeCtrl', function($scope) {
        $scope.pageClass = 'page-home';
    });

    app.controller('AboutCtrl', function($scope) {
        $scope.pageClass = 'page-about';
    });

    app.controller('ServiceCtrl', function($scope) {
        $scope.pageClass = 'page-contact';
    });

1 个答案:

答案 0 :(得分:0)

如果您已将<base href="/" >放入索引html文件中,请尝试将其注释掉。或者您可以将href的值更改为您想要的值。