If I use hashbang mode there's no problem and transition between routes will be smooth, however if I change the routing mode to Html5 mode transition between the routes won't be as smooth as hashbang mode and we see some sort of blinking in other parts of the page like header, panels, footer which is because of reloading the entire page.
With html5 mode, after changing the url the entire page will be reloaded even header and footer, how can I replace just the content and keep the other parts of the page intact?
angular.module("theApp", ["ngRoute"]);
angular.module("theApp").controller("MainController", [MainController]);
function MainController() {
var vm = this;
vm.headerContent = "Header Section";
}
angular.module("theApp").controller("FirstController", [FirstController]);
function FirstController() {
var vm = this;
vm.testField = "this is first controller";
}
angular.module("theApp").controller("SecondController", [SecondController]);
function SecondController() {
var vm = this;
vm.testField = "this is second controller";
}
angular.module("theApp").config(["$routeProvider", "$locationProvider", function ($routeProvider, $locationProvider) {
$routeProvider.when("/first", {
templateUrl: "../../static/web/first.html",
controller: "FirstController"
}).when("/second", {
templateUrl: "../../static/web/second.html",
controller: "SecondController"
});
$locationProvider.html5Mode(true);
}]);
<html lang="en" ng-app="theApp">
<head>
<meta charset="UTF-8">
<title>Django 103</title>
<base href="/user/">
</head>
<body ng-controller="MainController as MyMainCtrl">
<div class="header">
<h2 ng-bind="MyMainCtrl.headerContent"></h2>
</div>
<div ng-view></div>
</body>
</html>