0

I am using ng-route with html5 mode and http-server in npm. I have a main page with ng-view, and when i click on a link the view displays fine. But when i refresh only view display with out header. Below is

.config(['$routeProvider', function ($routeProvider) {
        //console.log($routeProvider);
        $routeProvider.
            when('/app/gateways', {
               templateUrl: '/app/gateways.html',
            }).
            when('/app/lights', {
               templateUrl: '/app/lights.html',
            }).
            when('/app/control', {
               templateUrl: '/app/assign-gateway-to-user.html',
            })
            //otherwise({
            //   redirectTo: '/app/index.html'
            //});
    }])
    .config(['$locationProvider', function($locationProvider)
    {
        $locationProvider.html5Mode({
            enabled: true,
            requireBase: false,
        });
    }])
Fotis Grigorakis
  • 363
  • 1
  • 3
  • 16
Phong Tran
  • 11
  • 2

1 Answers1

0

Change your code like this. You don't have to define config again to inject new providers. You can do that in a single step

.config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {
   //console.log($routeProvider);
   $locationProvider.html5Mode({
       enabled: true,
       requireBase: false,
   });
   $routeProvider.
   when('/app/gateways', {
       templateUrl: '/app/gateways.html',
   }).
   when('/app/lights', {
       templateUrl: '/app/lights.html',
   }).
   when('/app/control', {
           templateUrl: '/app/assign-gateway-to-user.html',
       })
       //otherwise({
       //   redirectTo: '/app/index.html'
       //});
 }])
Ivan
  • 34,531
  • 8
  • 55
  • 100
Vivz
  • 6,625
  • 2
  • 17
  • 33