Render delay with Angular + jQuery

Asked

Viewed 391 times

0

Some jQuery functions or Angular directives are not loaded or rendered on page loading.

At various points of the APP I had to apply the timeout to work everything normally.

I’m currently loading the angular this way, and right below I load the jquery, was the only solution for it to work, even if with timeout:

angular.element(document).ready(function(){
    angular.bootstrap(document, ['app']);

        jQuery(function($){
            $(window).load(function(){
                if($("‪#‎selection‬").length)
                    $(".languages").show();

What is the right way to use both at the same time and render everything without needing timeout?

1 answer

1


This is a very common doubt, the angular actually renders page and directive elements without having loaded some elements, this is normal. To correct this, there is a directive of the angular core itself called ngCloak, you can see how to use here in the documentations: https://docs.angularjs.org/api/ng/directive/ngCloak

It is necessary to note that you need to include css to disappear elements with the ngCloak attribute as stated in the directive specification.

[ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak], .ng-cloak, .x-ng-cloak {
  display: none !important;
}
  • I’d seen it before, but I didn’t even remember this directive... thanks Ricardo, hugs

Browser other questions tagged

You are not signed in. Login or sign up in order to post.