index.js
var express = require('express');
var mongoose = require('mongoose');
var bodyParser = require('body-parser');
var methodOverride = require('method-override');
var _ = require('lodash');
var cors = require('cors');
// Create the application.
var app = express();
//enable the use of cors
app.use(cors());
// Add Middleware necessary for REST API's
app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.json());
app.use(methodOverride('X-HTTP-Method-Override'));
// CORS Support
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');
res.header('Access-Control-Allow-Headers', 'Content-Type');
next();
});
app.models = require('./models/index');
// Load the routes.
var routes = require('./routes');
_.each(routes, function(controller, route) {
app.use(route, controller(app, route));
});
// Connect to MongoDB
var db = mongoose.connect('mongodb://localhost/isdbmeanapp');
mongoose.connection.on('error', console.error.bind(console, 'connection error:'));
mongoose.connection.once('open', function() {
// Load the models.
app.models = require('./models/index');
app.listen(3000);
console.log('Server running on localhost port 3000...');
});
我目前在我的数据库(mongodb)中有21个用户(虚拟数据)但是当我运行上面的restangular查询时,它只显示10个用户。我也试过用邮递员发出请求,同样的事情发生了(用206服务器状态代码)。
我使用restangular来提出我的要求:
Restangular.all('user').getList().then(function(user){
$scope.users = user;
});
请我帮忙解决这个问题...提前谢谢......