1

I'm having difficulties making ng-cloak work. I've tried everything on this page: ng-cloak

I have a ui-view containing 2 divs. The divs are mutually exclusive. I want to show only one of them. I'm trying to control this by using the ng-show / ng-hide pair.

  <div ng-controller="app.overviewController" ng-cloak>        
       <div name="a" ng-show="isFirst">
                     ...content
       </div>

       <div name="b" ng-hide="isFirst">
                     ...content
       </div>
   </div>

"isFirst" is being set with a call to a WebApi method, in the controller attached to this view. I have a hard time figuring out if i'm missing something. Any tips would be appreciated.

Community
  • 1
  • 1
VictorB
  • 371
  • 1
  • 4
  • 17
  • There is no `ng-cloak` shown in your code and we have no idea how `isFirst` is set. We can't help you troubleshoot `ng-cloak` if you don't show all the relevant code and css used. A demo that replicates problem would also help – charlietfl Feb 08 '16 at 14:58

2 Answers2

0

As stated here https://docs.angularjs.org/api/ng/directive/ngCloak You have to use ngCloak either as attribute or class

Here are the two approaches.

<div name="a" ng-cloak>...</div>
<div name="a" class="ng-cloak">...</div>
lisa p.
  • 2,138
  • 21
  • 36
0

If you are trying it during the page load time then you can achieve it like this:

<div ng-show="false">
Page is loading...  
</div>

In your above code snippets, I guess may be the isFirst variable should be initialized at the time of declaration.

Also try this way.

<div name="a" ng-show="isFirst">
     ...content
</div>

<div name="b" ng-hide="!isFirst">
   ...content
</div>
AAhad
  • 2,805
  • 1
  • 25
  • 42