I am encountering an issue with my code.
Whenever I refresh the page on localhost:portnumber/home or /todos or /contacts, it crashes ->
showing an error "Cannot GET /home" or /todos or /contacts.
The same problem occurs if I just enter localhost:portnumber/blablabla ->
it shows an error "Cannot GET /blablabla"
but if I enter just localhost:portnumber, it redirects to localhost:portnumber/home which is good!
I need to resolve the refresh problem and the unknown path
My ngRoute code :
angular.module('contactsApp' , ['ngRoute', 'ngMessages'])
/*
ROUTE configuration
when href is... do...
*/
.config(function ($routeProvider, $locationProvider) {
$routeProvider
.when('/contacts', {
controller: 'listCtrl',
templateUrl: '/views/list.html'
})
.when('/contacts/new', {
controller: 'newCtrl',
templateUrl: '/views/new.html'
})
.when('/contact/:id', {
controller: 'editCtrl',
templateUrl: '/views/edit.html'
})
.when('/todos', {
controller: 'todoCtrl',
templateUrl: '/views/noteslist.html'
})
.when('/home', {
controller: 'homeCtrl',
templateUrl: '/views/Home.html'
})
.otherwise({redirectTo: '/home'});
$locationProvider.html5Mode(true);
});
My index.html:
<html ng-app="contactsApp">
<head>
<base href="/">
<!-- Custom CSS -->
<link rel="stylesheet" href="src/css/style.css" type="text/css">
<link href="src/css/landing-page.css" rel="stylesheet">
<!-- Bootstrap Core CSS -->
<link href="src/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<!-- Navigation bar -->
<nav class="navbar navbar-default navbar-fixed-top topnav" role="navigation">
<div class="container topnav example2">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/home"><img src="images/logo_noback.jpg" alt="My Office" height="40px" width="auto"/></a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right increse-font-17">
<li>
<a href="home">Home</a>
</li>
<li>
<a href="todos">ToDo</a>
</li>
<li>
<a href="contacts">Contacts</a>
</li>
</ul>
</div>
</div>
</nav>
<!-- End Navigation bar -->
<!-- Changed page contact -->
<div class="navbar-overlap">
<div ng-view></div>
</div>
<!-- End Changed page contact -->
<!-- Sticky footer -->
<footer class="navbar navbar-default navbar-fixed-bottom topnav footer-backcolor">
<div class="col-md-12 margin-5">
<p class="col-md-6 breadcrumb visible-md visible-lg">Copyright © My Office 2016. All Rights Reserved</p>
<ul class="pull-right breadcrumb visible-md visible-lg">
<li><a href="/home">Home</a></li>
<li><a href="/todos">Todo</a></li>
<li><a href="/contacts">Contacts</a></li>
</ul>
</div>
</footer>
<!-- End Sticky footer -->
<script src="src/js/jquery.js"></script>
<script src="src/js/bootstrap.min.js"></script>
<script src="lib/angular/angular.min.js"></script>
<script src="lib/angular/angular-route.min.js"></script>
<script src="lib/angular/angular-messages.min.js"></script>
<script src="src/js/app.js"></script>
<script src="src/js/controller.js"></script>
<script src="src/js/filters.js"></script>
<script src="src/js/derectives.js"></script>
</body>