Questions tagged [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.

The directive can be applied to the <body> element, but the preferred usage is to apply multiple ngCloak directives to small portions of the page to permit progressive rendering of the browser view.

ngCloak works in cooperation with the following css rule embedded within angular.js and angular.min.js. For CSP mode please add angular-csp.css to your html file (see ngCsp).

[ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak], .ng-cloak, .x-ng-cloak {
  display: none !important;
}

When this css rule is loaded by the browser, all html elements (including their children) that are tagged with the ngCloak directive are hidden. When Angular encounters this directive during the compilation of the template it deletes the ngCloak element attribute, making the compiled element visible.

For the best result, the angular.js script must be loaded in the head section of the html document; alternatively, the css rule above must be included in the external stylesheet of the application

37 questions
66
votes
12 answers

How to correctly use ng-cloak directive?

Somehow, ng-cloak in AngularJS doesn't work. I want to hide {{ }} while loading the page. Because it looks awful. Angular Sample
Kotaro
  • 745
  • 2
  • 6
  • 7
17
votes
5 answers

Hide Angular brackets until javascript loaded

I have a few bits of HTML like

{{numberOfContacts}} Results Are Available

Is it possible for me to hide {{numberOfContacts}} until Angular has loaded? So it would just say Results Are Available I've seem some solutions…
TMH
  • 6,096
  • 7
  • 51
  • 88
9
votes
6 answers

angularjs ng-cloak is not working when page load

I am new to AngularJS and trying to fix the issue where some of the HTML code displays before ng-if condition gets evaluated. I am using ng-cloak as mentioned in many other stack over flow URLs but it still doesn't work for me. I am trying to load…
ree
  • 119
  • 1
  • 2
  • 6
4
votes
1 answer

ng-cloak has not effect whatsoever on blinking Angular code

When I hold down the F5 button on the following page, the AngularJS variables {{message}} and {{titleHelp}} blink on and off. I have read that to remove this I can put ng-cloak in the body tag. This, however, has no effect, i.e. it does not stop the…
Edward Tanguay
  • 189,012
  • 314
  • 712
  • 1,047
3
votes
2 answers

When not to use ng-cloak in AngularJs?

One query regarding AngularJS (ng-cloak), as per official docs: The ng-cloak directive is used to prevent the AngularJS HTML template from being briefly displayed by the browser in its raw (uncompiled) form while your application is loading. Use…
Hemant Singh
  • 1,487
  • 10
  • 15
3
votes
5 answers

html briefly displayed when page is loading

In my Angular app, my menu component html code is displayed briefly when the page is loading. Even if I hide the menu html root element with a display none css, the html is still displayed when the page start loading. I have read a lot of thing…
soung
  • 1,411
  • 16
  • 33
3
votes
0 answers

ng-cloak not working in firefox

Now I am working on some subview with coup ng-show for couple div, it works fine in chrome but not in FF.I searched online and did some tries, but none of them work for me, such as add .ng-cloak{display:none !important;} .state('accountsetting', …
linyuanxie
  • 777
  • 4
  • 13
  • 31
2
votes
0 answers

ng-cloak does not work with Firefox browser

Although using ng-cloak, some bindings are shown with brakets until getting data at firefox, not other browsers. Which workaround should I do?
Kle
  • 1,003
  • 2
  • 14
  • 24
2
votes
1 answer

execute directive function after ng-cloak

My content use ng-cloak directive and i would like to get a element height with innerHeight() in a directive. But, when the innerHeight() is use the element is hide by ng-cloak so the result is always 0. I tried link: function postLink(scope,…
Florian
  • 187
  • 3
  • 13
2
votes
0 answers

ng-cloak is not stopping the flickering of element

I am getting the flickering of content. Trying to resolve it by using ng-cloak but that's not working. I have one main view and multiple templates for separate views. My main view includes
user2138675
  • 95
  • 1
  • 2
  • 12
2
votes
2 answers

Showing the effect of ngCloak

I am working with my friend on an application and we decided to use the ngCloak directive to avoid the display of raw/uncompiled code. Since we are both relatively new to this we would like to know if there's a way to capture the effect of what…
Guy Meyer
  • 51
  • 8
2
votes
0 answers

Page flickers when Angular JS is used in Bootstrap modal, but works fine after reload. (tried ngCloak too)

Application Description: I am making a simple Ecommerce website(single page product listing) using AngularJS and Rails. It only handles Cash On Delivery Orders. The user adds products and checksout. All this process is done in Angular. The cart is…
2
votes
2 answers

AngularJS - show preloader instead of ng-cloak

I have created a preloader which works fine when loading the page first time: http://vivule.ee/1 However, when navigating inside the page, the loader does not work as intended. You can see this very well when using FF. Instead of the loader it just…
yodalr
  • 9,778
  • 10
  • 32
  • 47
2
votes
2 answers

Executing code at the end of angular initialization, and ngCloak display

I have a webpage written in angular with an ngCloak directive. It is loaded in a dynamically sized iframe with pym.js. The trouble is that the page does not appear unless I resize the browser or trigger a resize event, or call pymChild.sendHeight()…
Justin Dearing
  • 14,270
  • 22
  • 88
  • 161
1
vote
0 answers

What is the alternative of ng-cloak(angularjs) in Angular 7 for boolean variable not for object

ngIf causes links on my page to show during load time, and then disappear. The link is not supposed to show at all, and I am assuming that the ngIf statement hasn't been processed yet for the second I am able to see it. Is there a way to prevent the…
1
2 3