Tag: meanjs

mongoose中的填充函数是做什么的?

当我阅读http://mongoosejs.com/docs/populate.html时,我不明白这个问题。 我不完全理解populate函数的作用。 我从meanjs示例源代码中挑选出来的: Article.find().sort('-created').populate('user', 'displayName').exec(function (err, articles) { if (err) { return res.status(400).send({ message: errorHandler.getErrorMessage(err) }); } else { res.json(articles); }}); 提前致谢。

在运行Yeoman生成器时出错

我正在遵循mean.js的教程,而运行命令yo meanjs我有以下错误: 错误:错误:命令失败:C:\ Windows \ system32 \ cmd.exe / s / c“git –version”'git'n?o? 不被识别为内部或外部命令,可操作程序或batch file。 愿有人向我解释为什么我得到这个? 节点 – 版本 v4.3.1 哟 – 翻译 1.7.0 npm – 版本 3.7.5

在MEAN.js中使用Socket.io命名空间4.2

我正在用MEAN.js 4.2构build一个应用程序,并试图使用Socket.io让服务器发出一些UI将实时响应的消息。 例如,当服务器向用户的笔记本发布注释时,笔记本将在UI中刷新其内容。 我想使用命名空间来确保我只将事件发送给受影响的用户,并且用户只能监听相关事件。 在服务器上,我有: var namespace = '/player-' + user._id; // whereas user._id is the user's unique id var nsp = io.of(namespace); nsp.emit('note.posted', note); // whereas note contains info about the posted note 然后,在客户端控制器上: angular.module('myapp') .controller('NotebookController', ['$scope', '$state', '$stateParams', '$http', 'Authentication', 'Notebook', 'Socket', function ($scope, $state, $stateParams, $http, Authentication, Notebook, Socket) { … var […]

MEANJS:SocketIO中的安全性

情况 我在我的MEAN.JS应用程序中使用库的SocketIO 。 在NodeJS服务器控制器中 : var socketio = req.app.get('socketio'); socketio.sockets.emit('article.created.'+req.user._id, data); 在AngularJS客户端控制器中 : //Creating listener Socket.on('article.created.'+Authentication.user._id, callback); //Destroy Listener $scope.$on('$destroy',function(){ Socket.removeListener('article.created.'+Authentication.user._id, callback); }); 奥基。 效果很好… 问题 如果一个人(黑客或其他人)获得了用户的id ,他可以在另一个应用程序中在同一个频道中创build一个监听器,他可以监视发送给用户的所有数据。 例如所有的通知… 我怎么能做同样的事情,但更安全? 谢谢!

未知提供者试图在一个MeanJS v0.4.1应用程序中包含angular-websocket

在我正在使用的MeanJS应用程序中,在控制器中使用angular-websocket有点困难。 我的应用程序基于MeanJS v0.4.1。 我首先安装它: bower install angular-websocket –save 这创build了目录/ public / lib / angular-websocket 接下来我将它添加到/config/assets/default.js lib: { css: [ … ], js: [ … 'public/lib/angular-websocket/angular-websocket.js' ], tests: ['public/lib/angular-mocks/angular-mocks.js'] }, 在我的/modules/core/client/app/config.js文件中,我已经添加它作为依赖: var applicationModuleVendorDependencies = [ … 'angular-websocket' ]; 最后在我的angular度模块本身, angular.module('somemodule').controller('ModulenameController', ['$scope', '$http', '$stateParams', '$location', 'Authentication', 'SomeModule', 'ngWebSocket', function ($scope, $http, $stateParams, $location, Authentication, SomeModule, ngWebSocket) { […]

如何将mean.js部署到生产环境?

我已经build立了一个yeoman生成器 – mean.js应用程序 我已经build立了一个aws ec2 linux实例,我已经安装了nginx作为服务器,我已经设置了代理服务器的节点我已经设置了端口我已经使用grunt来构build我的dist文件夹,其中包括application.js,application.css, templates.js,vendor.js和vendor.css 我不能从这些文件本地或远程运行网站,它只适用于如果我使用开发环境,并加载80个人的个人js文件的网站,而不是我的新的uglified,串联的生产文件,所以我想知道我缺less什么在我的dist文件夹? (或一般) 我跟着这个教程: https : //blog.dylants.com/2014/11/19/bundling-production-assets-for-mean-js/最初,在运行grunt构build,我只有一个application.js和一个application.css文件 我尝试运行grunt prod并得到 Warning: Task "jshint:all" failed. Used –force, continuing. Running "eslint:target" (eslint) task Running "csslint:all" (csslint) task Warning: Unable to read ".csslintrc" file (Error code: ENOENT). Used –force, continuing. Running "ngAnnotate:production" (ngAnnotate) task >> 1 file successfully generated. Running "loadConfig" task Warning: […]

用哟生成器创buildmeanjs项目时出错

我是初学者意味着js,我从这里为meanjs做了设置。 我已经使用下面的命令来创build一个问题回答的meanjs项目。 santosh@santosh:~/Documents/Projects$ yo meanjs Native thread-sleep not available. This will result in much slower performance, but it will still work. You should re-install spawn-sync or upgrade to the lastest version of node if possible. Check /usr/local/lib/node_modules/yo/node_modules/yeoman-environment/node_modules/inquirer/node_modules/external-editor/node_modules/spawn-sync/error.log for more details Native thread-sleep not available. This will result in much slower performance, but it will still […]

在启动节点debugging服务器之后,Grunt停止输出信息

我的问题与此类似: Grunt不会加载节点服务器 但是,答案并不能解决我的问题。 这是我的gruntfile: 'use strict'; module.exports = function(grunt) { // Unified Watch Object var watchFiles = { serverViews: ['app/views/**/*.*'], serverJS: ['gruntfile.js', 'server.js', 'config/**/*.js', 'app/**/*.js'], clientViews: ['public/modules/**/views/**/*.html'], clientJS: ['public/js/*.js', 'public/modules/**/*.js'], clientCSS: ['public/modules/**/*.css', 'public/lib/bootstrap/dist/css/icomoon.css'], mochaTests: ['app/tests/**/*.js'] }; // Project Configuration grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), watch: { serverViews: { files: watchFiles.serverViews, options: { livereload: true } }, serverJS: […]

我在哪里把Angular代码放在这个Mean.js应用程序中,使这个列表可sorting?

按照@Pavlo的build议使用https://github.com/angular-ui/ui-sortable , 我有这个重复列表,我想sorting。 <div ui-sortable ng-model="regions" class="list-group region-list"> <a data-ng-repeat="region in regions" data-ng-href="#!/regions/{{region._id}}" class="list-group-item"> <h4 class="list-group-item-heading" data-ng-bind="region.name"></h4> </a> </div> 遵循@nrodic的build议,并将'ui.sortable'添加到config.js。 var applicationModuleVendorDependencies = ['ngResource', 'ngCookies', 'ngAnimate', 'ngTouch', 'ngSanitize', 'ui.router', 'ui.bootstrap', 'ui.utils', 'ui.sortable']; 但是,当我添加,我收到以下消息: “ui.sortable:jQuery应该包含在AngularJS之前!” 任何进一步的帮助,赞赏。 谢谢。

MEANJS用户configuration文件function

我正在尝试使用meanjs来构build一个简单的应用程序。 我有2个模块:标准的用户模块和职位模块。 我想实现的是一个用户configuration文件页面,它将显示有关特定用户和列表post属于该用户的一些信息。 你可以把它想成一个twitter个人资料页面。 我认为这也将是最好的/用户/用户名forms的url结构。 但我在这一切都相当新,现在卡住了。 这是我到目前为止所做的: 我将这些行添加到users.server.routes.js中: app.route('/api/users/:userName').get(users.userByUsername); app.param('userName', users.userByUsername); 像这样添加了一个function到服务器控制: exports.userByUsername = function(req, res, next, username) { User.findOne({ username: username }).exec(function(err, user) { if (err) return next(err); if (!user) return next(new Error('Failed to load User ' + username)); req.profile = user; next(); }); }; 我将这部分添加到users.client.routes.js state('view.profile', { url: '/users/:username', templateUrl: 'modules/users/views/view-profile.client.view.html' }); 我创build了这样一个新的看法: […]