【发布时间】:2019-03-13 02:25:40
【问题描述】:
我的应用文件:
var app = angular.module('app', ['ngRecourse', 'ngRoute']);
app.config(function($routeProvider, $locationProvider){
$routeProvider.when('/', { templateUrl: 'partials/main.jade', controller: 'mainCtrl '})
$locationProvider.html5Mode(true);
});
angular.module('app').controller('mainCtrl,' function($scope){
$scope.myVar = "Hello Angular";
});
与布局相关的索引页面和所需的所有脚本:
extends ../includes/layout
block main-content
section.content
div(ng-view)
layout.jade:
doctype
html
head
base(href='/')
link(href="/favicon.ico", rel="shortcut icon", type="image/x-icon")
link(rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous")
link(rel="stylesheet", href="/vendor/toastr/toastr.css")
link(rel="stylesheet", href="/css/site.css")
body(ng-app='app')
block main-content
include scripts
这是我的服务器:
app.get('/partials/:partialPath', function(req,res){
res.render('partials/' + req.params.partialPath);
});
app.get('*', function(req,res){
res.render('index.jade');
});
我尝试将应用程序脚本直接添加到索引中,但我得到的只是 localhost 上的白屏...我正在使用 Atom,并且我已经安装了我提到的所有软件包。感谢您的宝贵时间!
【问题讨论】:
标签: javascript angularjs node.js express pug