2015-04-23 52 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的重新启动,我得到服务全静文件,一切都很好,再次与世界!