所以我最近玩了用快速节点玉和棱角的均值堆栈;实际上我认为玉不知何故存在问题;对于复杂性,我深表歉意,但我真的想不通,希望从外部得到一些不同的看法;所以情况是这样的:
消息本身:
Uncaught Error: [$injector:modulerr] Failed to instantiate module app due to:
Error: [$injector:nomod] Module 'app' 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.3/$injector/nomod?p0=app
at https://ajax.googleapis.com/ajax/libs/angularjs/1.3.3/angular.js:63:12
好的,我们转到 63 的 angular js:return new ErrorConstructor(message);
-> 好吧,它什么也没告诉,但有些想法,问题真的隐藏在无处可去;
at https://ajax.googleapis.com/ajax/libs/angularjs/1.3.3/angular.js:1747:17
要么去看这个1747年:throw $injectorMinErr('nomod', "Module '{0}' is not available! You either misspelled " +
->这里没有什么可理解的;那么你怎么看呢?
at ensure (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.3/angular.js:1671:38)
at module (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.3/angular.js:1745:14)
at https://ajax.googleapis.com/ajax/libs/angularjs/1.3.3/angular.js:4041:22
at forEach (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.3/angular.js:322:20)
at loadModules (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.3/angular.js:4025:5)
at createInjector (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.3/angular.js:3951:11)
at doBootstrap (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.3/angular.js:1434:20)
at bootstrap (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.3/angular.js:1455:12)
http://errors.angularjs.org/1.3.3/$injector/modulerr?p0=app&p1=Error%3A%20%….googleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.3.3%2Fangular.js%3A1455%3A12)
文件结构:
_client
vendor //for bower installations
styles
application
angularCore.js
_server
views
core.jade
states
home.html
server.js
>
server.js :
==stuff===
app.set('views', path.join(__dirname, '_server/views'));
app.set('view engine', 'jade');
app.use(express.static(path.join(__dirname, '_client/')));
app.get('/states/:Path', function(req, res) {
res.render('states/' + res.params.Path + '.html');
});
app.get('*', function(req, res) {
res.render('core');
console.log(res);
});
==stuff==
_server/views/core.jade :
doctype html
html(lang="en")
head
link(rel="shortcut icon", href="favicon.ico", type="image/x-icon")
link(rel="stylesheet", href="styles/bootstrap.css")
link(rel="stylesheet", href="vendor/toastr/toastr.min.css")
link(rel="stylesheet", href="styles/core.css")
body(ng-app='app')
div(ng-view)
h1 Some text
script(type='text/javascript', src='vendor/jquery/dist/jquery.min.js')
script(type='text/javascript', src='https://ajax.googleapis.com/ajax/libs/angularjs/1.3.3/angular.js')
script(type='text/javascript', src='http://ajax.googleapis.com/ajax/libs/angularjs/1.3.3/angular-route.js')
script(type='text/javascript', src='http://ajax.googleapis.com/ajax/libs/angularjs/1.3.3/angular-resource.js')
script(type='text/javascript', src='./application/angularCore.js')
_client/应用/角度核心.js :
var app = angular.module('app', ['ngResource', 'ngRoute']);
app.config(function($locationProvider, $routeProvider) {
$locationProvider.html5mode(true);
$routeProvider
.when('/', {
templateUrl: '/states/home',
因此,正如我所看到的,问题 states/home.html 未加载到"网络"选项卡中;
controller: 'controllerMain'
});
}
app.controller('controllerMain', function($scope) {
$scope.myVar = "Hello peolm";
});
_server/views/states/home.html:
<h1>That's the state home</h1>
<h2>{{myVar}}</h2>
所以应用程序的逻辑是转到 localhost:3030 到"/",然后由于角度的
when('/', {
templateUrl: '/states/home',
和快递的
app.get('/states/:Path', function(req, res) {
res.render('states/' + res.params.Path);
});
收到家.html我们很好,但家.html没有渲染,甚至没有加载,我不知道是因为什么;通过浏览器、客户端下载的所有文件,除了"主页.html;
所以这是主要问题:全部下载,为什么找不到"应用程序"模块?
这很搞笑。
问题就在这里:$locationProvider.html5mode(true);
好吧,没有html5mode,而是html5Mode;
一看,我认为你在这里缺少.html
app.get('/states/:Path', function(req, res) {
res.render('states/' + res.params.Path + '.html');
});