JavaScript of HTML is loaded before than ng-include finished

613 views Asked by At

My problem is that my html load the .js and .css before ng-include finished, Then this libraries not found the elements that are loaded in include.

Example:

<html>
    <head>
         <link href="assets/css/modern.min.css" rel="stylesheet" type="text/css">
         <script src="assets/js/modern.min.js"></script>
    </head>

   <body>
         <div ng-include="html_2"></div>
   </body>
 </html>

when modern.js is loaded, html_2 is no finished so this not working because modern no found the element of html_2

1

There are 1 answers

2
Avraam Mavridis On BEST ANSWER

Where are you loading your angular application script? Maybe you can use a library like headJS or labjs to ensure the order of your scripts load.

e.g.

  head.load(modernjsScript, function(){
      head.load(angularjs, function(){
        head.load(yourApplicationsScript)
      });
    })