gpt4 book ai didi

javascript - AngularJS路由语法错误非法字符

转载 作者:行者123 更新时间:2023-12-03 10:17:08 25 4
gpt4 key购买 nike

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

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.04nginxPHP-FPM

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

问题是sendfile在虚拟环境中工作得不太好。修复结果非常简单——只需关闭 sendfile 即可。由于它是一台开发机器,关闭此功能所造成的性能影响可以忽略不计。 (这将是一个相当显着的性能损失,超过文件 chop !)在 nginx 配置 http 服务器 block 中,我添加了:

发送文件关闭;

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

关于javascript - AngularJS路由语法错误非法字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29817079/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com