私はNode.jsとExpressも使い慣れています。基本的なAngularJSアプリケーションを作成したいと思いますが、どこから起動するのかはわかりません。達成したいファイル構成は次のとおりです。基本的なアプリケーションを作成する - 平均
- public
----- app
---------- components
----------------- component0
----------------------- c0controller.js
----------------------- c0.html
----------------------- c0Service.js
----------------- component1
----------------------- c1controller.js
----------------------- c1.html
----------------------- c1Service.js
---------- assets [...]
----- index.html
----- app.js
----- module.js
- node_modules [...]
- server.js
- route.js
まず、それは可能ですか?
基本的には、index.html
ファイルは私の角型アプリケーションのui-view
を定義しています。
私の主な問題は、私が...セットアップにserver.js
の私のノードサーバが...ここで私は持っているが、私はすべての行を理解していない正直に言うと何であるかを知ることができないということです
// set up ========================
var express = require('express');
var app = express(); // create our app w/ express
var mongoose = require('mongoose'); // mongoose for mongodb
var morgan = require('morgan'); // log requests to the console (express4)
var bodyParser = require('body-parser'); // pull information from HTML POST (express4)
var methodOverride = require('method-override'); // simulate DELETE and PUT (express4)
var routes = require('./routes.js');
// configuration =================
mongoose.connect('mongodb://localhost/test'); // connect to mongoDB database
app.set('views', __dirname + '/public/app');
app.set('view engine', 'html');
app.use(express.static(__dirname + '/public')); // set the static files location /public/img will be /img for users
app.use(morgan('dev')); // log every request to the console
app.use(bodyParser.urlencoded({'extended':'true'})); // parse application/x-www-form-urlencoded
app.use(bodyParser.json()); // parse application/json
app.use(bodyParser.json({ type: 'application/vnd.api+json' })); // parse application/vnd.api+json as json
app.use(methodOverride());
app.get('/', routes.index);
app.get('*', routes.index);
// listen (start app with node server.js) ======================================
app.listen(8080);
console.log("App listening on port 8080");
そしてroutes.js
に、私は次のような方法エクスポート:
var exports = module.exports = {};
exports.index = function(req, res){
res.render('index');
};
を私はすでにejs
をのinstallerが、私はそれをどうするかわからないんだけど...私は任意の助けをいただければ幸いですので、少し迷ってしまいました。 )
シードを見ましたか?よう:https://github.com/meanie/express-seed – Alan
私はそれを明日行くありがとうございます;) –