search

Home  >  Q&A  >  body text

angular.js - Remove # sign from angularJS URL

The demo is downloaded from github. The following is the code of the routing part

phonecatApp.config(['$routeProvider', '$locationProvider',
    function ($routeProvider, $locationProvider) {
        $routeProvider.when('/phones', {
            templateUrl: 'partials/phone-list.html',
            controller: 'PhoneListCtrl'
        }).when('/phones/:phoneId', {
            templateUrl: 'partials/phone-detail.html',
            controller: 'PhoneDetailCtrl'
        }).otherwise({
            redirectTo: '/phones'
        });
        //$locationProvider.html5Mode(true);
    }]);

This html5Mode method does not seem to work. I added the base tag to the index.html page. When running, the browser will report a 404 error. I want to know what went wrong

过去多啦不再A梦过去多啦不再A梦2814 days ago544

reply all(2)I'll reply

  • 阿神

    阿神2017-05-15 17:03:30

    This method is not suitable for local testing. It can be deployed on the server

    reply
    0
  • 滿天的星座

    滿天的星座2017-05-15 17:03:30

    The pound sign is used by ng to mark its own route. Without the pound sign, it means that every time you access it, it will request the corresponding path from the server. However, your server does not have the corresponding path, so it cannot be found. You can solve it through nginx configuration. You should be able to find it by searching "angular remove pound sign" on Baidu.

    reply
    0
  • Cancelreply