Angular-UI роутер загружает шаблон Jade
Я пытаюсь объединить Express с Angular и, в частности, Angular-UI Router и использовать Jade: мой index.jade выглядит так:
doctype html
html(lang="en")
head
meta(charset='UTF-8')
meta(name='fragment', content='!')
base(href='/')
title Node Express Angular Example
meta(name='viewport', content='width=device-width, initial-scale=1.0')
link(rel='stylesheet', href='//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css')
link(rel='stylesheet', href='./css/style.css')
body(style='', ng-app='myApp', ng-cloak)
include partials/header
div(ui-view)
script(src='//code.jquery.com/jquery-2.1.1.min.js')
script(src='//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js')
script(src='https://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js')
script(src='http://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.10/angular-ui-router.min.js')
script(src='https://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular-sanitize.js')
script(src='./js/app.js')
Мой app.js выглядит так:
var myApp = angular.module('myApp', ['ui.router']);
myApp.config(['$stateProvider','$urlRouterProvider','$locationProvider',
function ($stateProvider,$urlRouterProvider,$locationProvider) {
$stateProvider
.state('home', {
url:'/home',
templateUrl: './partials/partial-home.jade'
})
.state('about', {
url:'/about',
template: 'This is the about page'
});
$urlRouterProvider.otherwise('/home');
$locationProvider
.html5Mode(true)
.hashPrefix('!');
}]);
И мой частично-home.jade выглядит так:
div.jumbotron
div.container.text-center
h1 Home Page
p This page is a draft in progress
У меня нет проблем с просмотром страницы «О программе», но я не могу просмотреть домашнюю страницу. Я также пытался заменить div (ui-view) на<div ui-view></div>
в index.jade, как было предложено в каком-то другом посте SO, но безрезультатно. Есть какие-нибудь подсказки?
Изменить: В app.js произошла орфографическая ошибка, это templateUrl вместо templateURL. Тем не менее, он по-прежнему не отображает правильный файл part-home.jade, то, что находится внутри пользовательского интерфейса, фактически совпадает с index.jade. Мой server.js выглядит так:
var express = require('express');
var app = express();
var port = process.env.PORT || 8080;
var favicon = require('serve-favicon');
var path = require('path');
app.set('views', __dirname+'/client/views');
app.set('view engine', 'jade');
app.use(express.static(path.join(__dirname, 'client')));
app.get("/*", function (req, res) {
console.log(req.url + req.method);
res.render('index');
});
app.listen(port, function () {
console.log('Express Server listening on ' + port);
});