All elements with the ng-hide
attribute are visible until the page loads (and angular hide them) – it makes a strange web page appearance until that. With jquery, I was used to set style="display:none"
and show them when the js is done.
Am I doing something wrong in AngularJS? Or is there a better way to solve this?
Thanks a lot!
Example of the page showing all hidden elements while loading:
(Best) Use the ng-cloak directive which will hide the content until Angular has finished processing it.
AngularJS ng-hide Directive The ng-hide directive hides the HTML element if the expression evaluates to true. ng-hide is also a predefined CSS class in AngularJS, and sets the element's display to none .
Absolutely not. First of all, the two directives can trip over each other( see this JSFiddle, as provided by Joel Skrepnek), and is generally just bad design. You can use a function, another field or just some more inline-logic.
Just Try
<div ng-app ng-cloak>
//Code
</div>
Docs https://docs.angularjs.org/api/ng/directive/ngCloak
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With