Home Ask Login Register

Developers Planet

Your answer is one click away!

VictorB February 2016

AngularJs elements flicker

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">

       <div name="b" ng-hide="isFirst">

"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.


lisa p. February 2016

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>

AAhad February 2016

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

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

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">

<div name="b" ng-hide="!isFirst">

Post Status

Asked in February 2016
Viewed 1,555 times
Voted 7
Answered 2 times


Leave an answer

Quote of the day: live life