Hemant Singh
Hemant Singh

Reputation: 1598

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 this directive to avoid the undesirable flicker effect caused by the HTML template display.

Does this mean that we should always use this in the AngularJS app? Or are there any side-effects of using it all the time?

Upvotes: 3

Views: 363

Answers (2)

Surya Priyadarshi
Surya Priyadarshi

Reputation: 1

Angular provides the ng-cloak directive to try and hide the element it cloaks so that you don’t see the flash of these markup expressions when the page initially loads before Angular has a chance to render the data into the markup expressions. Note the ng-cloak attribute on this element, which here is an outer wrapper element of the most of this large page’s content. ng-cloak is supposed to prevent displaying the content below it, until Angular has taken control and is ready to render the data into the templates. For more details visit :https://weblog.west-wind.com/posts/2014/Jun/02/AngularJs-ngcloak-Problems-on-large-Pages

Upvotes: -1

Pritam Banerjee
Pritam Banerjee

Reputation: 18923

This is the suggestion in the official website:

The directive can be applied to the 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.

So for slow internet the page will be white for a while, which is definitely not a desired outcome.

Upvotes: 1

Related Questions