Tag: angularjs

用Node.js和Express.js和AngularJs和nodemiailer发送邮件不发送邮件

我已经看过各种教程,并通过使用Node.js和Express.js通过HTML和AngularJs页面发送基本电子邮件做了许多search,但根本无法让我的实现工作。 我知道我错过了一些愚蠢的东西。 我select使用nodemailer作为Node.js包,并在我的Express.js API中使用它来发送实际的邮件。 从我的视图到API的path如下 :查看(表单)>>控制器>>电子邮件工厂>> API 我得到了每个步骤的结果(数据的控制台日志),但电子邮件失败。 在Chrome开发工具中,我在Headers中获得了200 OK的状态代码,但实际上失败了。 当我查看“响应”或“预览”时,会看到以下消息: {error: "connect ETIMEDOUT 64.233.184.109:465"} error:"connect ETIMEDOUT 64.233.184.109:465" 在Bash控制台(我正在运行我的服务器),我可以看到API端点被击中,因为我得到这个console.log输出: THIS IS THE API HIT:Email to: corne.leroux@outlook.comSubject: This is my subjectMessage: This is my message 我一直在使用的一些参考文献: http://javascript.tutorialhorizo​​n.com/2015/07/02/send-email-node-js-express/ https://blog.ragingflame.co.za/2012/6/28/simple-form-handling-with-express-and-nodemailer 我是Express.js的绝对新手,并且对Node.js的了解有限。 这是我的基本实现: HTML视图: <div class="container"> <form name="createEmailForm" method="post" action="" class="form-horizontal" role="form"> <div class="form-group"> <label for="emailAddress" class="col-lg-3 col-md-3 col-xs-12 […]

将angularjs数据ID发送到我的节点服务器

我想发送ID到我的节点服务器。 但我不知道如何得到它的服务器端。 需求被发送。 console.log(req.body)返回空… 控制器: $scope.remove = function(id) { var idstring = JSON.parse(id); $http.delete('/contactlist/remove', {data: idstring}).then(function(response){ $scope.contactlist = $scope.contactlist.filter(function(contact){ return contact.id !== id; }) }); }; 服务器: app.delete('/contactlist/remove', function (req, res) { console.log(req.body); // connection.query('DELETE FROM contactlist WHERE id = ' + req.body.id, function (error, results, fields) { res.json(); // }); }); Chrome中的DELETE请求屏幕截图:

自动部署,刷新(清除caching)和重新加载您的代码为Web开发人员

我正在寻找一些与“离子服务”相匹配的内容,这将检测我对源代码(源文件夹/ WebContent)所作的任何更改,并且: 自动部署 自动刷新我的浏览器 所以我不需要手动执行部署 – >右键单击我的浏览器 – >清空caching – >重新加载我的浏览器

expressionPOST req.body分析器是空的

我看到堆栈溢出类似的问题,并find解决scheme使用: app.use(bodyParser.urlencoded({ extended: true })); app.use(bodyParser.json()); 但是,当打印日志req.body是空白的。 app.js内容: var express = require('express'); var path = require('path'); var app = express(); var bodyParser = require('body-parser'); // Define the port to run on app.set('port', 8888); app.use(express.static(path.join(__dirname, '/webapp/public'))); app.use(bodyParser.urlencoded({ extended: true })); app.use(bodyParser.json()); app.post('/getsolution', function (req, res) { console.log("request body is",req.body); //—-req.body is blank here }); 从angular度发布请求代码如下 var […]

客户端无法击中自己的服务器端点

我有一个AngularFullStack项目,我试图用下面的代码打我的项目的服务器端点,但问题是调用不是从angular度客户端到nodejs服务器。 由于这是我的第一个项目,我很less不知道可能会出现什么问题,可能会导致这个奇怪的冲突。 客户端: $http({ method: 'POST', url: '/api/soapAPIs/soapAPI', data: request, headers: { 'Content-Type': 'application/json' } }) .then(function(response) { console.log("response from server is: ", response); }) .catch(function(error) { console.log("error in calling server is: ", error); }); 我已经在服务器端安装了CORS,并在app.js中写下了下面的代码,但仍然无效。 服务器App.js // Setup server var app = express(); var cors = require('cors'); //add cors to do the cross site […]

将数组从数据库传递到控制器AngularJs

我有一个这个应用程序,我正在build设学习AngularJs的一个小问题。 这是一个足球统计应用程序。 我从2个下拉菜单中select主队和客队。 然后,我必须做一些math运算,只显示结果。 这是我的html代码: <div class='dropdown'> <span>Seleziona Nazione: </span> <select class='opzioni' ng-model="nazioniSelected"> <option ng-repeat="nazione in nazioni track by $index" value="{{nazione}}">{{nazione}} </option> </select> </div> <div class='dropdown2'> <span>Seleziona Campionato: </span> <select class='opzioni' ng-model="campionatoSelected"> <option ng-repeat="team in teams | filter: {Paese:nazioniSelected} track by $index" value="{{team.Campionato}}">{{team.Campionato}} </option> </select> </div> <div class='SquadraCasa'> <span>Seleziona Squadra Casa: </span> <select class='opzioni' ng-model="HomeTeamSelected" […]

AngularJS数据绑定不能与附加到DOM的`<div>`一起工作

这里是我的代码来帮助理解我的问题: var app = angular.module('myProfile', []); app.controller('myWrapperCtrl', ['$scope', '$http', function ($scope, $http) { $scope.fetchData = function() { $http.post('/rankData', { id: $('h2.name').attr('id')}).then(function(response) { $scope.data = response.data; var newElement = angular.element('<div class="myRanks">{{data}}</div>'); var target = document.getElementsByTagName('body'); if ($('.myRanks').length === 0) { angular.element(target).append(newElement); } }); }; }]); 在上面的代码中,我基本上创build了一个div,并分配了variables数据 ,这些数据稍后将填充我从post请求中获取的数据。 <button type="button" id="ranks" ng-click="fetchData()">Ranks</button> 在我的ejs文件中,我已经设置了一个简单的过程,当我按下buttonfetchData()被调用,正如我所提到的,创build一个div与所谓的post请求数据,在这种情况下,它不。 它只是打印出{{data}}而不是来自发布请求的数据。 为了进一步的澄清,我发布了一个截图 ,以更直观的方式展示了这个问题。 我find的一个解决scheme是,而不是'<div […]

将数据发布到mongoDb后如何获得id?

我正在使用node.js,angularjs和mongoDb。 我正在创build一个产品上传页面。 它分为两部分: 数据页面 :这部分将包含文本框和下拉菜单。 图片上传页面 :这个部分会有图片上传控件。 所以我想在同一页面创build2个表单,从第一页我将文本数据发布到mongoDb,返回新创build的产品的product_id ,然后上传带有返回的product_id的图像。 我开发了restFul API来发布产品api/products/create-product 。 产品型号 : { productName:{type: String}, productPrice:{type: Number} } 图像模型 : { productId:{type: String}, imagePaths:[{type: Array}] } 产品控制器(Angular): $scope.newProduct = function(){ var formData = new FormData; for(key in $scope.product){ formData.append(key, $scope.product[key]); } //getting the files var file = $('#file')[0].files[0]; formData.append('image', file); //Post data $http.post('http://localhost:3000/products/api/new-product',formData,{ […]

将POST请求数据JSON路由到视图/控制器(node.js)

基本上,我正在从本地服务器( http:// localhost:3000 / )接收来自另一个服务器的发布请求,如下所示: return requestLib.post({ url: 'http://localhost:3000/test', timeout: 120000, json: true, body: { user: user, proposal: proposal } }); 我想在本地服务器上使用这个post请求中的json来为从这个post请求收到的json创build视图。 这是我目前在我的本地主机服务器上的routes.js文件中做的: app.post('/test', function(req, res) { res.render('index', req.body); res.end(); }); 我的问题是我如何使用这个作为我的控制器范围内收到的JSON和我的本地服务器的意见? 我非常新的angular度和节点,因为如果这是一个愚蠢的问题或没有意义,你可能会告诉我们道歉

login后将用户带回上一页(节点)

我希望能够将未经身份validation的用户从单个post的页面redirect到login,然后在用户login后重新回到post。 我的login路线是这样的: router.get('/login', function(req, res, next){ if (req.user){ res.redirect('/wall'); } else { res.render('login'); } }); 我的墙壁路由器是这样的: router.get('/wall', function(req, res, next){ res.render('wall'); }); post的URL将会是这样的: http://thisisnotarealdomain.com/wall#/post/ID 我的堆栈是:SPA的NodeJS和Angular 我怎么做? 谢谢,