javascript - AngularJS ngCloak not working -


i have post category page should show message if there no posts. it's showing html when page loads , hiding it. ngcloak sounds should job i'm not having luck it. here's html in template file:

  <div ng-show="data.posts.length == 0" ng-cloak>     <div class="no-posts">       <h2>coming soon</h2>       <p>sorry there posts here yet, check soon.</p>     </div>   </div> 

here's css i've added sass file. tried adding directly css on page did not work:

[ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak], .ng-cloak, .x-ng-cloak {   display: none !important; } 

what missing? should simple right?

edit: added html head , didn't work:

<style type="text/css">   [ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak], .ng-cloak, .x-ng-cloak {     display: none !important;   } </style> 

ng-cloack directive works in way expect it. not hide html, show once template becomes compiled. reason template compilation in browser takes time upon ugly template without data shown user. hide uncompiled template need add ng-cloak class (to make invisible) , ng-cloack directive show after template compilation. problem describe here has solution: have add 'ng-hide' class element, , hidden until expression ng-show wont take 'true' value.

window.settimeout(function() {    angular.module('demo', [])     .controller('democontroller', ['$timeout', function($timeout) {       var vm = this;            vm.isloaded = true;    }]);  angular.bootstrap(document, ['demo']);  }, 3000);
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"></script>  <div ng-controller="democontroller vm">  <div>message below appear in 3 seconds</div>  <div class="ng-hide" ng-show="vm.isloaded">data loaded</div>  </div>


Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -