Hello i have a problem with my code. When i click on link page isn`t reload.
Here is a HTML and JS code:
var app=angular.module('mainApp',['ngRoute']);
app.config(function($routeProvider){
$routeProvider
.when('/',{
templateUrl: 'home.html'
})
.when('/about',{
templateUrl: 'about.html'
});
.when('/contact',{
templateUrl: 'contact.html'
});
.otherwise({ redirectTo: '/'});
});
app.controller('mainCtrl',function($scope){
});
<div ng-controller="mainCtrl">
<div>
<nav>
<ul>
<li><a href="#/">Home</a></li>
<li><a href="#/about">About us</a></li>
<li><a href="#/contact">Contact</a></li>
</ul>
</nav>
</div>
<br/>
<div ng-view >
</div>
</div>
Remove semicolon (;) for second and thirs .when cases
var app=angular.module('mainApp',['ngRoute']);
app.config(function($routeProvider){
$routeProvider
.when('/',{
templateUrl: 'home.html'
})
.when('/about',{
templateUrl: 'about.html'
})
.when('/contact',{
templateUrl: 'contact.html'
})
.otherwise({ redirectTo: '/'});
});