2016-08-03 104 views
1

我有這樣的代碼:NG-包括angularjs拋出錯誤

<!DOCTYPE HTML> 
<html> 
    <head> 
     <script src="angular.js"></script> 
     <script src="angularmy.js"></script> 
     <link rel="stylesheet" href="angular.css"/> 
    </head> 
    <body ng-app="myMod" ng-controller="myCont"> 
     <div ng-include="'angular3.html'"> 
     </div> 
    </body> 
</html> 

所有文件都在同一個文件夾,甚至angular3.html但是當我嘗試運行它給我這個錯誤:

Error: NETWORK_ERR ([arguments not available])@file://localhost/C:/Users/amondapr/Desktop/html/angularjs/ng-include/angular.js:12014 sendReq([arguments not available])@file://localhost/C:/Users/amondapr/Desktop/html/angularjs/ng-include/angular.js:11776 serverRequest([arguments not available])@file://localhost/C:/Users/amondapr/Desktop/html/angularjs/ng-include/angular.js:11571 processQueue([arguments not available])@file://localhost/C:/Users/amondapr/Desktop/html/angularjs/ng-include/angular.js:16383 ([arguments not available])@file://localhost/C:/Users/amondapr/Desktop/html/angularjs/ng-include/angular.js:16399 ([arguments not available])@file://localhost/C:/Users/amondapr/Desktop/html/angularjs/ng-include/angular.js:17682 ([arguments not available])@file://localhost/C:/Users/amondapr/Desktop/html/angularjs/ng-include/angular.js:17495 ([arguments not available])@file://localhost/C:/Users/amondapr/Desktop/html/angularjs/ng-include/angular.js:17790 bootstrapApply([arguments not available])@file://localhost/C:/Users/amondapr/Desktop/html/angularjs/ng-include/angular.js:1761 invoke([arguments not available])@file://localhost/C:/Users/amondapr/Desktop/html/angularjs/ng-include/angular.js:4718

有沒有其他人遇到過這個問題,如果是的話怎麼改正呢?

+0

我認爲你需要把你的應用程序的角度在網絡服務器上(如wampserver或無業遊民箱) –

+0

但爲什麼???我正在關注的教程將他們的html文件放在同一目錄 – YepMe

+0

是的,但是整個目錄通過http服務器提供。 –

回答

2

您必須運行本地http服務器。

最簡單的方法是使用python -m http.server(使用Python 3)在應用程序文件夾中運行。 然後,你可以訪問http://localhost:8000

0

如果你是在Mac上,你可以使用MAMP