angular.js - Remove # sign from angularJS URL
过去多啦不再A梦
过去多啦不再A梦 2017-05-15 17:01:30
0
2
537

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梦

reply all(2)
阿神

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

滿天的星座

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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template