Answer the question
In order to leave comments, you need to log in
How to remove block flicker in angular?
The header added via ng-switch flickers, which should be shown only to authorized users, but when switching pages, the contents of ng-view are loaded first, and then only ng-switch. How can you synchronize them?
<body>
<div ng-switch on="selection">
<div ng-switch-when="1">
</div>
</div>
<div data-ng-view>
</div>
</body>
.run(function ($rootScope, $location, Data) {
$rootScope.$on("$routeChangeStart", function (event, next, current) {
$rootScope.authenticated = false;
$rootScope.selection = 0;
Data.get('session').then(function (results) {
if (results.uid) {
$rootScope.authenticated = true;
$rootScope.uid = results.uid;
$rootScope.name = results.name;
$rootScope.email = results.email;
$rootScope.selection = 1;
} else {
var nextUrl = next.$$route.originalPath;
if (nextUrl == '/signup' || nextUrl == '/login') {
} else {
$location.path("/login");
}
}
});
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question