Reputation: 6246
I have a few bits of HTML like
<p class="noresults">{{numberOfContacts}} Results Are Available</p>
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 such as hiding the entire body until Angular has loaded, but I'd rather not do that if possible.
Upvotes: 17
Views: 9399
Reputation: 5870
This is typically only an issue when working with complex content on really slow devices. In those instances, there can be a brief moment when the browser displays the HTML in the document while AngularJS is parsing the HTML, getting ready, and processing the directives. In this interval of time, any inline template expressions you have defined will be visible to the user. Most devices nowadays have pretty good browsers which are quick enough to prevent this from being an issue. There are two ways to solve the problem.
I have seen issues with ng-cloak not working when added to an element. In the past, I have worked around this issue by simply adding ng-cloak class to element.
Upvotes: 1
Reputation: 1885
You can use ng-bind instead of expression like
<span ng-bind="data"></span>
Upvotes: 0
Reputation: 151
Sometimes, even if I used the ng-cloak
, I could still see the braces for a few seconds. Adding the following style resolved my issue:
[ng-cloak]
{
display: none !important;
}
Please see this link link for more explanation.
Hope it helps :D
Upvotes: 2
Reputation: 496
use <span ng-bind="numberOfContacts" />
instead of {{numberOfContacts}}
Upvotes: 9
Reputation: 13597
Yes, use ng-cloak. Simply add class="ng-cloak"
or ng-cloak
to an element like this
Using directive <div ng-cloak></div>
Using class <div class="ng-cloak"></div>
It's simply a set of CSS rules with display: none !important
and as Angular has rendered your DOM it removes the ng-cloak so an element is visible.
Upvotes: 33