AngularJS路由语法错误非法字符

AngularJS route syntax error illegal character

我正在尝试向我的网站添加一个新页面(它是由其他人开发的),当我向路由添加另一个块时,我收到如下错误:

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>

关于这是怎么回事以及我怎样才能摆脱这个错误的任何帮助?值得一提的是,当我收到该错误时,网页看起来一团糟。

我搞定了。这与angular无关,而与nginx有关。让我们更深入地告诉你发生了什么:

我正在使用这个流程来完成我的项目:Ubuntu 12.04, nginx, PHP-FPM

Nginx 有一个 sendfile 指令,默认为打开。它允许 nginx 使用 Linux 内核的 sendfile() 操作从磁盘读取请求的文件。这通常比使用 read()write() 更快。到目前为止,还不错。

问题是 sendfile 在虚拟环境中效果不佳。修复结果出奇地简单——只需关闭发送文件。由于它是一台开发机器,关闭此功能对性能的影响可以忽略不计。 (这将是一个相当重要的性能损失,以超过文件截断!) 在 nginx 配置 http 服务器块中,我添加了:

sendfile off;

重新启动 nginx 后,我得到了完整的静态文件,一切都恢复正常了!