Angular JS – ngCloak to prevent Angular template from being displayed

While an Angular application is still loading is possible to view for a while the raw template in its uncompiled form. In this case we will see all the {{ stuff }} instead of the bounded values and the effect could be ugly.

To avoid this we can use the ngCloak directive. This directive can be set as an attribute (“ng-cloak” or “data-ng-cloak”) or as a class (“ng-cloak”). We also have to add a specific CSS rule to handle it:

.ng-cloak {
        display: none !important;

This will hide out template by default. The cool thing is that while Angular is processing the template it automatically remove this directive, so the template will not appear until the application is completely loaded.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s