Tag: 平均堆栈

获取一个错误“str.substr不是一个函数”当使用我的浏览器的本地主机页面,但服务器正在运行?

在启动服务器后请求我的网页时,出现以下错误(服务器正常运行,请求页面时发生问题): TypeError: str.substr is not a function at createGetter (C:\Users\mypath\node_modules\method-override\index.js:88:11) at methodOverride (C:\Users\mypath\node_modules\method-override\index.js:50:7) at Layer.handle [as handle_request] (C:\Users\mypath\node_modules\express\lib\router\layer.js:95:5) at trim_prefix (C:\Users\mypath\node_modules\express\lib\router\index.js:312:13) at C:\Users\mypath\node_modules\express\lib\router\index.js:280:7 at Function.process_params (C:\Users\mypath\node_modules\express\lib\router\index.js:330:12) at next (C:\Users\mypath\node_modules\express\lib\router\index.js:271:10) at logger (C:\Users\mypath\node_modules\morgan\index.js:144:5) at Layer.handle [as handle_request] (C:\Users\mypath\node_modules\express\lib\router\layer.js:95:5) at trim_prefix (C:\Users\mypath\node_modules\express\lib\router\index.js:312:13) 我还在学习关于MEAN栈,请耐心等待,我的server.js如下: var express = require('express'), favicon = require('serve-favicon'), stylus = require('stylus'), logger = require('morgan'), methodOverride […]

将数据推送到MongoDB,而不需要编辑MEAN中的整个条目

所以我有一个单一的页面应用程序通过MEAN堆栈运行。 我有一个Klausur的计划/模型(Klausur是德语考试,我想pipe理考试)。 var KlausurSchema = new Schema( { name: String, semester: String, krankmeldungen: [Number], aufgaben: [{ name: String, punkte: Number }], studenten: [{ matrnr: Number, vorname: String, nachname: String, bewertung: [{ punkte: Number }], pversuch: String, pvermerk: String, freiverm: String, labnr: Number, porgnr: Number, aenddat: String }] } ); 多个用户可以编辑entrys,否则我只会覆盖条目。 我想要一张由“学生”组成的桌子,是否可以把一个学生推到我的“学生”,而不需要对整个“Klausur”进行PUTTING(编辑),也就是说,我想把信息推送到一个数组而不覆盖整个数据库条目! 提前致谢!

为什么/公共文件夹中的静态内容在node.js中

在具有express的node.js中,所有静态内容都放在/ public文件夹中。 有人可以帮我理解为什么我们需要把它放在公共文件夹? 如果我想在“views”文件夹中创build一个名为“static”的文件夹,并将所有图像,样式和脚本文件保存在该文件夹中。 因为我想保留与一个文件夹下的视图有关的所有东西。 如果这不是构build项目的好方法,请帮助我理解背后的原因。

dynamic页面标题使用MEAN堆栈 – Jade和Angular

在我的MEAN堆栈应用程序中,我试图根据页面上加载的内容来改变页面标题(设置为翡翠)。 目前,它显示SPA内每个页面的通用页面标题。 要设置索引的页面标题,我正在这样做 index.js res.render('index', { title: 'Generic Page Title' }); 那么当我返回内容(不同的angular度路线/页面)我想更新这个标题 offers.js Offer.find(searchObject).sort('-pricing.pctSavings').exec(function(err, offers){ if (err) { res.render('error', { status: 500 }); } else { //update title? res.jsonp(offers); } }); head.jade title= appName+' – '+title 我不确定如何更改此优惠作为json在页面中返回。 我已经尝试将标题添加到响应(res.locals.title ='testing唯一标题'),但它不起作用。 有任何想法吗? 谢谢! 添加更多信息: 我可以在jade模板中包含一些html,如下所示: head.jade head div(data-ng-include="'views/dynamic_title.html'") meta(charset='utf-8') meta(http-equiv='X-UA-Compatible', content='IE=edge,chrome=1') meta(name='viewport', content='width=device-width,initial-scale=1,user-scalable=no') 意见/ dynamic_title.html <div data-ng-controller="OffersController"> […]

Angularjs从express.js的“public”文件夹的“views”文件夹中路由ejs静态文件

这是我的项目结构。 我试图从“public”文件夹中的angular度路由文件(app> public> main.js)中的“views”文件夹中调用ejs文件(app> views> list.ejs)。 但list.ejs不加载。 /************main.js****************/ var fsApp=angular.module('chart-app'); fsApp.config(function($routeProvider) { $routeProvider .when('/', { templateUrl: 'list.ejs', controller: 'listCtrl' }) /*In my server.js server file I am calling the files in public folder this way: */ app.use('/static',express.static(__dirname + '/public')); app.get('/',function(req,res){ res.render('index.ejs'); }); <!–In index.ejs (where my <ng-view></ng-view> is) I am including the link for static […]

如何使AngularJS的$ http请求到本地服务器上的应用程序?

目前的情况 我试图从Angular中发出$ http post请求,在我的控制器中定义了以下函数: $scope.sendUserData = function(){ var userData = JSON.stringify({ 'firstName': $scope.firstName, 'lastName': $scope.lastName, 'email': $scope.email }); console.log(userData); //this prints out the JSON I want var config = { headers: { 'Content-Type': 'json' } }; $http.post('/api/users', userData, config) .success(function(data){ console.log(data); }) .error(function(data){ console.log('Error: ' + data) }); 我有一个Express API,我想要接收这个$ http post请求与下面定义的路由处理程序: router.route('/users') .post(function(req, res){ […]

意味着堆栈authentication – 最佳实践

我试图找出build立一个最简单的authentication系统(基于user_name和密码)的最佳做法。 我search了最佳实践,并find了一些项目,虽然他们大多数都很老,许多东西都折旧了。 我想有一些最佳做法build议有最简单的login\注册系统使用angular-express-mongodb。

为什么我的AngularJS / Express / Socket.io应用程序不能提供socket.io.js文件?

我有一个Angular / NodeJS应用程序,join了一些实时function的Socket.io支持。 我想添加MongoDB和PassportJS支持,所以我已经迁移到了generator-angular-fullstack结构。 突然间,Socket.iofunction不再工作了。 我发现的一个错误是由http://localhost/socket.io/socket.io.js的Socket.io提供的客户端JS库现在返回的是我的应用程序中的index.html页面。 这听起来像一个路由问题,所以这里是我的路由configuration: lib / routes.js(NodeJS): module.exports = function(app) { // Server API Routes app.get('/api/awesomeThings', api.awesomeThings); app.post('/api/users', users.create); app.put('/api/users', users.changePassword); app.get('/api/users/me', users.me); app.get('/api/users/:id', users.show); app.post('/api/session', session.login); app.del('/api/session', session.logout); // All other routes to use Angular routing in app/scripts/app.js app.get('/partials/*', index.partials); app.get('/*', middleware.setUserCookie, index.index); app.get('/:session', function(req, res) { res.render('views/index.html', { title: 'Weld […]

无法使用MEAN堆栈显示图像

我正在使用MEAN堆栈,并试图显示存储在我的Mongo数据库中的图像。 我相信图像被正确存储并正确传递到浏览器,因为当我使用Web控制台,并看看我的post响应身体显示图像的响应。 我有一个表,当一个单击行时,它会打电话给我的控制器: $scope.detailRequest = function(index){ $scope.selectedRow = index; $scope.selected = this.contact; $http.post('/DetailRequest', $scope.selected).success(function(response){ $scope.detailResponse = response; }); }; 在节点我查询Mongo并返回图像: router.post('/DetailRequest', function(request, response) { reports .findOne({_id : request.body._id}) .select('img') .exec(function (err, research) { response.contentType(research.img.contentType); response.send(research); }); }); 我正在使用ng-src进行图像显示。 正如我在页面顶部提到的,我可以在Web控制台的Response Body中正确地看到图像。 因此,我有信心将图像传回浏览器。 <img ng-src="{{detailResponse}}"> 图像不会显示

为什么bin / www命令不能在我的cloud9(c9)新的运行configuration中工作?

我正在跟随一个关于MEAN Stack开发的Lynda课程,当他们在“新运行configuration”中运行bin / www命令时,以及其产生的“侦听端口15454的debugging器” 而对于我来说,当我inputbin/www ,我得到以下错误: debugger listening on port 15454 module.js:340 throw err; ^ Error: Cannot find module '/home/ubuntu/workspace/bin/www' at Function.Module._resolveFilename (module.js:338:15) at Function.Module._load (module.js:280:25) at Module.runMain [as _onTimeout] (module.js:497:10) at Timer.listOnTimeout [as ontimeout] (timers.js:112:15)