J
J
jenya77712016-08-16 11:10:05
Angular
jenya7771, 2016-08-16 11:10:05

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

1 answer(s)
N
Nikolai, 2016-08-17
Demidovets @Nik_o_lay

use ng-cloak
web.izjum.com/angularjs-ng-cloak-loading-indecato

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question