2

When I reload page my AngularJS code is displaying

enter image description here

Problem: Code should not display if my internet is slow or page not fully reload. It should display just result.

Please help me with the best solution.

Muhammad Riaz
  • 403
  • 3
  • 8
  • 23

2 Answers2

4

ng-cloak is for the same usage. Read it here https://docs.angularjs.org/api/ng/directive/ngCloak

The ngCloak directive is used to prevent the Angular html template from being briefly displayed by the browser in its raw (uncompiled) form while your application is loading. Use this directive to avoid the undesirable flicker effect caused by the html template display.

Or, you can also replace your content from

<div>{{cat1.Title | limitTo:18}}</div>

To like this:

<div ng-bind="cat1.Title | limitTo:18"></div>
Shashank Agrawal
  • 25,161
  • 11
  • 89
  • 121
3

Using ngCloak is the right approach.

Make sure to add CSS too, based on this post: Angularjs - ng-cloak/ng-show elements blink

/* 
  Allow angular.js to be loaded in body, hiding cloaked elements until 
  templates compile.  The !important is important given that there may be 
  other selectors that are more specific or come later and might alter display.  
 */
[ng\:cloak], [ng-cloak], .ng-cloak {
  display: none !important;
}
Community
  • 1
  • 1
Michael Kang
  • 52,003
  • 16
  • 103
  • 135