2016-07-25 75 views
0

這是後我跑我的角度aaplication角js腳本加載

<!DOCTYPE html> 
<html class="no-js" ng-app="BasicHttpAuthExample"> <!--<![endif]--> 
    <head> 
     <script src="<?= ASSETS_PATH ?>/js/app2.js"></script> 
     <script src="<?= ASSETS_PATH ?>/js/main.js"></script> 
     <script src="http://localhost/SPA_DEMO/assets/js/jquery.countTo.js"></script> 
    </head> 
    <body ng-app="BasicHttpAuthExample"> 
     <nav id="fh5co-main-nav" role="navigation"> 
      <a href="#" class="js-fh5co-nav-toggle fh5co-nav-toggle active" id="Close"><i></i></a> 
      <div class="js-fullheight fh5co-table"> 
       <div class="fh5co-table-cell js-fullheight"> 
        <ul> 
         <li></li> 
         <li class="active"><a href="index.html">Home</a></li> 
         <li><a href="gallery.html">Gallery</a></li> 
         <li><a href="services.html">Services</a></li> 
         <li><a href="about.html">About</a></li> 
         <li><a href="contact.html">Contact</a></li> 
        </ul> 
       </div> 
      </div> 
     </nav> 
    <ng-view> 
    </ng-view> 
</body> 
</html> 

在這個當我加載在這個文件中加載視圖腳本是不是在視圖中可用。如何在每次加載視圖時加載一些腳本或如何在視圖中加載可用的加載腳本。

+0

從html標記中刪除屬性'ng-app =「BasicHttpAuthExample」''。 –

+0

爲什麼你有兩個ng-app =「BasicHttpAuthExample」,你的ng-controller(s)指令在哪裏,你在「查看腳本」下的含義是什麼?也很高興看到你的js文件的內容。不要在這裏添加內容,更好的方法是創建一個重要鏈接並提供鏈接。祝你好運 – Antipod

回答

0

嘗試確保您在body標記附近的底部加載腳本,以便在加載dom時加載它們。還要確保像Jquery和其他庫這樣的外部腳本首先被加載,因爲你的javascript文件可能依賴於它們。

您不必指定兩次ng-app指令。它的身體標籤沒關係。 你也缺少一個控制器指令。

<html class="no-js" > <!--<![endif]--> 
    <head> 

    </head> 
    <body ng-app="BasicHttpAuthExample" ng-controller="//your controller"> 
     <nav id="fh5co-main-nav" role="navigation" > 
      <a href="#" class="js-fh5co-nav-toggle fh5co-nav-toggle active" id="Close"><i></i></a> 
      <div class="js-fullheight fh5co-table"> 
       <div class="fh5co-table-cell js-fullheight"> 
        <ul> 
         <li></li> 
         <li class="active"><a href="index.html">Home</a></li> 
         <li><a href="gallery.html">Gallery</a></li> 
         <li><a href="services.html">Services</a></li> 
         <li><a href="about.html">About</a></li> 
         <li><a href="contact.html">Contact</a></li> 
        </ul> 
       </div> 
      </div> 
     </nav> 

    <ng-view> 
    </ng-view> 
     <script src="http://localhost/SPA_DEMO/assets/js/jquery.countTo.js"></script> 
     <script src="<?= ASSETS_PATH ?>/js/app2.js"></script> 
     <script src="<?= ASSETS_PATH ?>/js/main.js"></script> 

</body> 
</html>