是否可以在 NodeJS 上使用纯 HTML、ExpressJS 构建 angularJS 应用程序?
最佳答案
No 没有必要,您可以在 Node 和 Express 中使用不同的模板引擎,或者您可以只发送纯 HTML 文件。
Jade 只是 Express.js 自带的默认模板引擎,如果你想要一个接近裸 html 的模板引擎,我认为 dust.js 是一个不错的选择。
坦率地说,angular.js 与此无关。
您可以像这样设置 express 来呈现纯 html 文件。
app.configure(function(){
app.set("view options", {
layout: false
});
app.register('.html', {
compile: function(string, options){
return function(locals){
return string;
};
}
});
});
然后像这样渲染
app.get('/myUrl', function(request, response){
response.render("index.html");
});
或者,当我在前端使用 ember 时,在 jade 模板中编写 handlebars 模板非常矛盾,所以在我的 jade 模板中,我简单地包含了一个像这样的纯 html 文件。
include '/handlebars/templates.html';
关于node.js - 使用 Node 和 Express 构建 Angular 应用程序时是否有必要使用 JADE?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19880060/