2015-04-23 32 views
0

我想一個新的頁面添加到我的網站(它是由別人開發的),當我再添塊路線我只是得到一個錯誤,如:AngularJS路線語法錯誤非法字符

Error: [$injector:modulerr] Failed to instantiate module nameApp due to: [$injector:nomod] Module 'nameApp' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument. http://errors.angularjs.org/1.3.12/ $injector/nomod?p0=nameApp

我的路由配置:

.config(
     function($routeProvider, $locationProvider) 
     { 
      $routeProvider 
       .when('/home', { 
       templateUrl: 'templates/home.html', 
       title: 'Home', 
       controller: 'HomeController', 
       reloadOnSearch: false 
      }) 
      .when('/about', { 
       templateUrl: 'templates/about.html', 
       reloadOnSearch: false 

      }) 
      .otherwise({ redirectTo: '/404' }); 
      $locationProvider.html5Mode(true); 
     } 
    ) 

我沒有與此配置中的任何問題,因爲它在Web瀏覽器加載好的,但是當我嘗試添加:

.when('/donate', { 
    templateUrl: 'templates/donate.html', 
    reloadOnSearch: false 
    }) 

我收到上面的錯誤。 (我也創建了donate.html文件)

的index.html

<li> 
    <a ng-class="getClass('/')" title="Home" href="/">Home</a> 
</li> 
<li> 
    <a ng-class="getClass('/about')" title="About Us" href="/about">About Us</a> 
</li> 
<li> 
    <a ng-class="getClass('/donate')" title="Donate" href="/donate">Donate</a> 
</li> 

什麼會出現這種情況怎麼可能我擺脫錯誤的任何幫助嗎?如提到的,當我收到該錯誤時,網頁看起來像一團糟。

+1

你在哪裏定義'nameApp'? – Ofiris

+1

在同一個js文件中。問題是當我添加新的頁面。否則,網站可以使用 –

+1

聽起來像是一種語法錯誤,它會阻止Angular創建'nameApp'模塊。 – Ofiris

回答

1

我已經完成了。這與角度無關,但與nginx無關。讓我們去更深,並告訴你發生了什麼:

我使用這個流程,纔能有做我的項目:的Ubuntu 12.04nginx的PHP-FPM

的Nginx有的sendfile指令,默認爲on。它允許nginx使用Linux內核的sendfile()操作從磁盤讀取所請求的文件。這通常比使用read()write()更快。到現在爲止還挺好。

問題是sendfile在虛擬環境中不能很好地工作。修復竟然是非常簡單 - 只需將sendfile關閉。由於它是一個開發機器,因此關閉此功能導致的性能下降幾乎可以忽略不計。 (!它想成爲一個相當顯著的性能命中大於文件截斷) 在nginx的配置HTTP服務器塊,我說:

sendfile off;

一旦nginx的重新啓動,我得到服務全靜文件,一切都很好,再次與世界!