Tag: angularjs

使用mongodbembedded集合

我刚开始使用mongodb和nodejs。 我知道mongodb不支持连接。我只是在mongodb中插入数据,我的文档看起来像: { "_id": ObjectId("564dacf84d52785c1d8b4567"), "content": "This blog created by karanSofat", "html": "<p>This blog created by karanSofat</p>\n", } 现在用户对这个post发表评论。 它应该是这样的: { "_id": ObjectId("564dacf84d52785c1d8b4567"), "comments": [ { "name": "sumit", "email": "sumit@ggi.net", "comment": "this is also well for me", "posted_at": ISODate("2015-11-19T11:06:27.172Z") } ], "content"▼: "This blog created by karanSofat", "html": "<p>This blog created by karanSofat</p>\n", } 这是我的模特, […]

logout()不能使用passport.js,express.js,AngularJs

猜猜我没有足够的睡眠,无法弄清楚。 遵循weblogin在线样本,loginbutton的作品,而不是注销button,注销不在server.js调用。 非常感谢 ! app.config(['$routeProvider', function($routeProvider) { $routeProvider.when('/login', { templateUrl: '/partials/login.html', controller: 'authController' }); $routeProvider.when('/logout', { templateUrl: '/partials/logout.html', controller: 'authController', }); … ); app.controller('authController', function($scope, $http, $location, $window) { $scope.user = {username:'', password:''}; $scope.alert = ''; $scope.login = function(user) { $http.post('/auth/login', user). success(function(data) { console.log("you are at /auth/login 0"); $scope.loggedUser = data; $window.location.href = "/index.html#/systemStatus"; […]

无法从$ http.post获取数据

所以基本上,我有一个表单,我不能获取input的数据(我使用angular和node.js) req.body req.params都是空的 我的html表单: <form ng-submit="sendTradelink()"> <md-input-container class="md-accent"> <label>Enter your tradelink</label> <input ng-model="tradelink"> </md-input-container> <md-button type="submit" class="md-raised md-accent">Send</md-button> </form> 控制器: $scope.sendTradelink = function () { Auth.send() .success(function (res) { $location.path('/'); }); } 服务: authFactory.send = function (tradelink) { return $http.post($api.url + 'tradelink', {tradelink: tradelink}); }; 服务器端文件,我想要处理插入到表单中的数据: api.post('/tradelink', function(req, res){ console.log(req.user.id); console.log(req.params); console.log(req.body); res.json({ success: true, […]

无法加载ngRoute模块

我正在使用Angular的Node.js项目,我试图实现多个视图和路由。 我已经按照这里列出的说明安装了angular-route.js文件和依赖模块: https://docs.angularjs.org/api/ngRoute 但我仍然在控制台中得到这个错误: Uncaught Error: [$injector:modulerr] Failed to instantiate module blogApp due to: Error: [$injector:modulerr] Failed to instantiate module ngRoute due to: Error: [$injector:nomod] Module 'ngRoute' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument. […]

使用Angular routeProvider和Express路线

我正在尝试使angular的routeProviderpipe理我的应用程序的所有路线。 我在angular(客户端)的app.js文件中相应地定义了我的路由: (function(){ var app = angular.module("Crowdsourcing", ["ngRoute"]); app.config(function($routeProvider){ $routeProvider .when("/single/:street/:buildingNumber/:apartmentNumber", { templateUrl: "/views/single.html'", controller: "ListingCtrl" }) .otherwise({redirectTo:"/"}); }); }()); 然而,当在浏览器上写入一个URL(例如/ single)时,试图由我的后端express / node api来处理这个请求。 因此,它不会被find,因为后端路由是例如/ api / foo。 我如何确保Angular的routeProvider始终pipe理我的请求? 更重要的是应用程序的基本stream程是什么? 当客户端编写一个URL时,应用程序如何知道url是由express js还是由routeProvider处理?

nan.h在安装AngularJS时出现exception

我从Windows 8.1计算机上的AngularJS开始,但有一些问题来build立该项目。 节点版本:5.1.1 NPM版本:3.5.1 运行时 npm install 在angular-phonecat文件夹中它会在一段时间后抛出这个错误: C:\ Users \ MyTest \ angular-phonecat \ node_modules \ ws>如果没有定义npm_config_node_gyp(节点“C:\ Users \ MyTest \ AppData \ Roaming \ npm \ node_modules \ npm \ bin \ node -gyp-bin \ … 。\ node_modules \ node-gyp \ bin \ node-gyp.js“rebuild)else(node rebuild)一次构build一个解决scheme中的项目。 要启用并行构build,请添加“/ m”开关。 bufferutil.cc C:\ Users \ MyTest \ […]

Node.js可写入stream创build错误的文件(更大和不可读)

我正在写一段代码,通过Socket.io将文件从Angular.js客户端发送到Node.js服务器。 客户端将文件分块并通过Socket.io发送到服务器。 该文件在客户端使用JavaScript的FileReader读取: var chunkSize = 524288, // 0.5mb reader = new FileReader(); reader.onload = function(e) { // ok, this one is very simplified so that I don't have to copy // all of my code here, but basically I send files with an offset // like: // file.data.substr(offset, Math.min(chunkSize, file.size – offset)); // for […]

在我的项目结构中,我应该在哪里pipe理服务器端的高级algorithm/服务?

我正在使用RESTful API使用nodejs,expressjs,mongodb和angular。 这是我的项目结构。 — config — models — public —- css —- js —— controllers —— services —- views — routes // API route 一切都很好,因为我的API调用很简单,大部分的逻辑都是通过服务angular度来pipe理的。 但是现在我必须实现高级algorithm和一些逻辑服务器端,我不知道该怎么做。 我应该添加另一个服务文件夹服务器端? 你将如何pipe理它?

如何使用用户input的关键字在Node.js中执行Twitter APIsearch

我是Node.js,Express和Angular的完全新手。 我在localhost上运行了一个Node / Express应用程序。 我正在尝试使用Twitter API将其转换为Twittersearch应用程序,以便我可以inputsearch词并且API返回此search词的search结果。 为此,我使用twitter包 。 在index.js ,我已经在X中填入了我的Twitter密钥和秘密,如下所示: var Twitter = require('twitter'); var client = new Twitter({ consumer_key: 'X', consumer_secret: 'X', access_token_key: 'X', access_token_secret: 'X' }); 然后,当我把下面的代码放入index.js ,关键字“awesome”的search结果被logging到控制台: var tmpSearch = 'awesome'; client.get('search/tweets', {q: tmpSearch}, function(error, tweets, response){ if (error) throw error; console.log(tweets); }); 这工作。 我的主页使用一个控制器myCtrl ,它确保当用户按下searchbutton(具有属性ng-click="search(searchTerm)" )时,input的search项被分配给variablessearchTerm(使用ng-model="searchTerm"作为input区域)。 控制器的代码如下所示: app.controller('myCtrl', ['$scope', function($scope){ $scope.search […]

正确检索用户名和有用的值(网站标题,版权等)

我有一个基于这个项目的简单的Web应用程序( https://github.com/arthurkao/angular-drywall ),以NodeJS和AngularJS作为前端运行。 我正在设置一个简单的页面,显示地图上所有已连接用户的列表(使用Google地图,地理位置和PubNub)。 以下是我如何做到这一点: angular.module('base').controller('TravelCtrl', function($rootScope, $scope, NgMap, security, $geolocation, PubNub){ $rootScope.extusers = []; //remote users $scope.initTravel = function() { //declare the init function PubNub.init({ subscribe_key: $rootScope.security.keys.psk, publish_key: $rootScope.security.keys.ppk, uuid: $rootScope.security.currentUser.username, ssl: true }); PubNub.ngSubscribe({ channel: "travel", state: { position: {}, } }); console.log("Loaded Travel"); $geolocation.getCurrentPosition({ timeout: 60000 }).then(function(position) { //when location is retreived […]