angular js ng-view返回blanc partials – Express / Jade

我正在编写一个angular度的应用程序下面的教程。 令我惊讶的是,我完全按照我的节点js开始没有问题。 但是,我的angular没有返回模板,假设。 我在这里看到类似的问题相同的教程和相同的问题。 但是,这个问题没有回答。 以下是我的dir结构

app.js

var app = angular.module('app', ['ngResource', 'ngRoute']); angular.module('app').config(function($routeProvider, $locationProvider){ $locationProvider.html5Mode(true); $routeProvider .when('/', { templateUrl: 'partials/main', controller: 'mainCtrl'}); }); angular.module('app').controller('mainCtrl', function($scope){ $scope.myVar = "Hello Angular"; }); 

我的layout.jade

 doctype html head link(rel="styleSheet",href="css/bootstrap.css") link(rel="styleSheet",href="vendor/toastr/toastr.css") link(rel="styleSheet",href="css/site.css") body(ng-app='app') block main-content include scripts 

我的main.jade

 h1 This is a partial h2 {{ myVar }} 

我的server.js路由设置为

 app.get('partials/:partialPath',function(req,res){ res.render('partials/' + req.params.partialPath); }); app.get('*', function(req,res){ res.render('index'); }); 

我的index.jade

 extends ../includes/layout block main-content section.content div(ng-view) 

虽然我认为这不应该是一个问题,因为我是从一个页面的一部分的部分视图开始。 当我跑,我的页面返回黑色。 我检查元素,并确保所有的js和css在哪里加载。 当我查看源代码时,生成了下面的html源代码。

 <!DOCTYPE html> <head><link rel="styleSheet" href="css/bootstrap.css"> <link rel="styleSheet" href="vendor/toastr/toastr.css"> <link rel="styleSheet" href="css/site.css"> </head> <body ng-app="app"> <section class="content"> <div ng-view></div></section> <script type="text/javascript" src="vendor/jquery/dist/jquery.js"></script><script type="text/javascript" src="vendor/angular/angular.js"></script> <script type="text/javascript" src="vendor/angular-resource/angular-resource.js"></script> <script type="text/javascript" src="vendor/angular-route/angular-route.js"></script><script type="text/javascript" src="app/app.js"></script> </body> 

我在这里怀疑我的app.js的routeProvider

 .when('/', { templateUrl: 'partials/main', controller: 'mainCtrl'}); 

试着

 .when('/', { templateUrl: '/partials/main', controller: 'mainCtrl'}); 

一切都无济于事。 请问我哪里错了? 我已经尝试了一切可能。 我甚至重新开始了,但仍然是白色的。 任何帮助,将不胜感激。

感谢您的时间。 事实certificate,这个问题是在我的布局

 doctype html head link(rel="styleSheet",href="css/bootstrap.css") link(rel="styleSheet",href="vendor/toastr/toastr.css") link(rel="styleSheet",href="css/site.css") body(ng-app='app') block main-content include scripts 

变成

  doctype html head base(href='/') link(rel="styleSheet",href="css/bootstrap.css") link(rel="styleSheet",href="vendor/toastr/toastr.css") link(rel="styleSheet",href="css/site.css") body(ng-app='app') block main-content include scripts 

缺less的是

 base(href='/') 

它不会加载模板,如果您删除该基地。 我从另一个tutvideo中学到了这个东西。“[Tuts Plus]用AngularJSvideo教程从头开始构buildWeb应用程序”。 主持人特别提到了重要的base(href='/')并警告不要忘记。 或者,@Alex Choroshin 在这里有另一个很好的例子。 你应该下载他build议的文档。 它是一个完美的例子。 谢谢