make an element with ng-if start hidden (prevent it from showing during page load)
Asked Answered
C

1

7

When i want to make something start as hidden with ng-show you can just add class="ng-hide" so the css will hide the element beforehand. This way an element won't be shown when the page is still loading

I want to do the same thing using ng-if but i don't know how to do it

Culex answered 27/1, 2016 at 15:51 Comment(1)
Maybe using ng-cloak is a solution for you? docs.angularjs.org/api/ng/directive/ngCloakEdition
N
8

As Michiel suggested, using the ngCloak directive is the solution.
Just add ng-cloak to the class attribute of the tag you want to keep hidden while your application is loading.

<div class="ng-cloak">test</div>

For more details: https://docs.angularjs.org/api/ng/directive/ngCloak

Neurologist answered 27/1, 2016 at 16:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.