我想一个新的页面添加到我的网站(它是由别人开发的),当我再添块路线我只是得到一个错误,如: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>
什么会出现这种情况怎么可能我摆脱错误的任何帮助吗?如提到的,当我收到该错误时,网页看起来像一团糟。
你在哪里定义'nameApp'? – Ofiris
在同一个js文件中。问题是当我添加新的页面。否则,网站可以使用 –
听起来像是一种语法错误,它会阻止Angular创建'nameApp'模块。 – Ofiris