W
W
westdp2016-07-26 15:07:21
Angular
westdp, 2016-07-26 15:07:21

Page reload when using $locationProvider?

Hello guys, I have already read a lot of documentation and forums on how to solve the problem with page reloading or direct access, for example, using the link: " localhost:7852/dev/views/login "
I am making a single-page application using routing ($ routeProvider) to load the desired template in index.html

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

app.config(function ($routeProvider, $locationProvider) {
  var server_url = 'http://localhost:7852/dev/views/'
  $locationProvider.html5Mode({
    enabled: true,
    requireBase: false
  });
  $routeProvider.when('/login', {
    templateUrl: 'login/login.html',
    controller: 'loginCtrl'
  });
  $routeProvider.when('/products', {
    templateUrl: 'products/products.html',
    controller: 'CategoryCtrl'
  });
  $routeProvider.when('/forgot-password', {
    templateUrl: 'forgot-password/forgot-password.html',
    controller: 'loginCtrl'
  });
  $routeProvider.when('/new-account', {
    templateUrl: 'new-account/new-account.html',
    controller: 'loginCtrl'
  });
  $routeProvider.when('/recent-addresses', {
    templateUrl: 'recent-addresses/recent-addresses.html',
    controller: 'RecentAddressesCtrl'
  });
  $routeProvider.when('/categories', {
    templateUrl: 'categories/categories.html',
    controller: 'CategoriesCtrl'
  });
  console.log($locationProvider);
});

<!DOCTYPE html>
<html>

<head>
  <title>Nostrum App</title>
  <base href="/dev/views/">
  <link href="../css/style.css" rel="stylesheet">
</head>

</html>

<body ng-app="nostrum"><a href="/dev/views/login">Login</a>
  <br><a href="/dev/views/products">Products</a>
  <br><a href="/dev/views/recent-addresses">Recent Addresses</a>
  <br><a href="/dev/views/categories">Categories</a>
  <ng-view class="view-animate"></ng-view>
</body>
<script src="../js/scripts.js" type="text/javascript"></script>

Everything works fine, but when we refresh the page after the transition or go directly to the link, it gives a 404 error.
I use the Gulp server, but I think it has nothing to do with it.
Thanks

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question