I have an angular application and I want to load the entire page template after the user logs in
Here is my login code
$scope.login = function (event) {
event.preventDefault();
Auth.login({
username: $scope.username,
password: $scope.password,
rememberMe: $scope.rememberMe
}).then(function () {
$scope.authenticationError = false;
if ($rootScope.previousStateName === 'register') {
$state.go('home');
} else {
$location.path("dashboard");
}
}).catch(function () {
$scope.authenticationError = true;
});
};
When I navigate to the dashboard - I had hoped that all my controllers would load again but they dont Specifically I want to reload my header controller so the users name and image appears on screen - it is only reloaded when I press F5
Is there anyway to force a reload of controllers when a user is successful in the login?
Cheers Damien
index.html code with javascript imports
<!doctype html>
<!--[if lt IE 8]> <html class="no-js lt-ie8"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
<title>Page</title>
<meta name="description" content="Responsive Admin Web App">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<link href='http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,400,600,300,700' rel='stylesheet' type='text/css'>
<!-- Needs images, font... therefore can not be part of main.css -->
<link rel="stylesheet" href="fonts/themify-icons/themify-icons.min.css">
<link rel="stylesheet" href="jsLibs/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="jsLibs/weather-icons/css/weather-icons.min.css">
<!-- end Needs images -->
<!-- build:css({.tmp,client}) styles/main.css -->
<link rel="stylesheet" href="styles/bootstrap.css">
<link rel="stylesheet" href="styles/ui.css">
<link rel="stylesheet" href="styles/main.css">
<!-- endbuild -->
</head>
<body data-ng-app="app"
id="app"
class="app"
data-custom-page
data-off-canvas-nav
data-ng-controller="AppCtrl"
data-ng-class=" {'layout-boxed': admin.layout === 'boxed'} "
>
<!--[if lt IE 9]>
<div class="lt-ie9-bg">
<p class="browsehappy">You are using an <strong>outdated</strong> browser.</p>
<p>Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
</div>
<![endif]-->
<section data-ng-include=" 'views/header.html' "
id="header"
class="header-container "
data-ng-class="{ 'header-fixed': admin.fixedHeader,
'bg-white': ['11','12','13','14','15','16','21'].indexOf(admin.skin) >= 0,
'bg-dark': admin.skin === '31',
'bg-primary': ['22','32'].indexOf(admin.skin) >= 0,
'bg-success': ['23','33'].indexOf(admin.skin) >= 0,
'bg-info-alt': ['24','34'].indexOf(admin.skin) >= 0,
'bg-warning': ['25','35'].indexOf(admin.skin) >= 0,
'bg-danger': ['26','36'].indexOf(admin.skin) >= 0
}"></section>
<div class="main-container">
<aside data-ng-include=" 'views/sidebar.html' "
id="nav-container"
class="nav-container"
data-ng-class="{ 'nav-fixed': admin.fixedSidebar,
'nav-horizontal': admin.menu === 'horizontal',
'nav-vertical': admin.menu === 'vertical',
'bg-white': ['31','32','33','34','35','36'].indexOf(admin.skin) >= 0,
'bg-dark': ['31','32','33','34','35','36'].indexOf(admin.skin) < 0
}">
</aside>
<div id="content" class="content-container">
<section data-ng-view
class="view-container {{admin.pageTransition.class}}"></section>
</div>
</div>
<!-- endbuild -->
</body>
</html>
enter code here
ng-includesuse Angular expressions. Then you change them from your controller to kick theng-includeto reload.ng-viewwould work also.