AngularJS routing without the hash '#'

前端 未结 10 1091
野性不改
野性不改 2020-11-22 01:40

I\'m learning AngularJS and there\'s one thing that really annoys me.

I use $routeProvider to declare routing rules for my application:

         


        
10条回答
  •  天命终不由人
    2020-11-22 02:17

    Lets write answer that looks simple and short

    In Router at end add html5Mode(true);

    app.config(function($routeProvider,$locationProvider) {
    
        $routeProvider.when('/home', {
            templateUrl:'/html/home.html'
        });
    
        $locationProvider.html5Mode(true);
    })
    

    In html head add base tag

    
    
            
        
    
    

    thanks To @plus- for detailing the above answer

提交回复
热议问题