Tag: angularjs

使用angular.js和node.js将集合中的集合插入另一个服务器

这是我的控制器代码,我想把它发送到服务器,在那里服务器将数据存储在集合中。 $scope.addIdeas = function(){ console.log($scope.idea); var post_data = null; post_data = $scope.idea; console.log(post_data); $http({ url: 'http://127.0.0.1:3300/myroute/', method: 'post', }).then(function(response) { console.log(res); post_data = $scope.idea; console.log('from the function add' + post_data); }); }; 然后,这是我的服务器代码,我收到请求将其放入集合中。 //Adding the ideas to database app.post('/addIdeas', function(req, res){ console.log('i get req from idea controller'); console.log(req.body); db.ideas.insert(req.body, function (err, docs){ console.log(docs); res.json(docs); }); […]

在Express中响应数据到Slack url

在我的Node后端,我有以下路由与快递中间件。 我的应用程序使用Slack反斜杠api发布一个链接到用户的频道。 当用户点击它时,在heroku上托pipe的angular度应用程序上打开一个表单。 我想要做的是在表单提交时更新Slack用户。 所以这个问题,我怎样才能发送一个post请求松弛url当下面的路线被触发(很明显res是指向/更新)。 我已经研究了很多,并尝试重写头文件,并使用低级别的http方法,但我有一种感觉,有一个更好的解决scheme。 非常感谢您的帮助。 app.post("/update", function(req,res,next) { res url -> http://slackapi/12345/ res.json({"text":"hello":} })

用angularJS更新mongodb中的date,inputtypes=“date”

我有一个MongoDb 学生collections。 一个学生可以有一些包含开始和结束的课程(opl)。 我使用Mongoose在server.js中创build一个REST接口: //adres Schema var adresSchema = new mongoose.Schema({ gemeente: String, post: Number, straat: String }) //opl Schema var oplSchema = new mongoose.Schema({ oplcode: Number, geslaagd: Boolean, startdatum: Date, einddatum: Date, }) //Studenten Schema var studentSchema = new mongoose.Schema({ voornaam: String, familienaam: String, email: String, adres: adresSchema, foto: String, ikl: Number, opl: [oplSchema], […]

在通过从mongoose中获取数据连接的angularjs中自动完成

嘿家伙 , 我正在调查Angularjs中的自动完成字段,它从mongoose获取数据…这样的东西https://stackoverflow.com/questions/18460374/angularjs-autocomplete-from-http但事情是我dint理解正确…如果你们帮我简单的例子,它会很高兴! 提前致谢!!!

CORS请求问题(XMLHttpRequest)

我在Node js和Angularjs的前端开发了一个服务器,但是当我尝试从我的前端发出请求时出现错误: XMLHttpRequest无法加载http:// localhost:8085 / server / authenticate / 。 对预检请求的响应不会通过访问控制检查:请求的资源上不存在“Access-Control-Allow-Origin”标头。 原因' http:// localhost:9000 '因此不被允许访问。 我的代码在我的server.js app.use(function(req,res,next){ res.setHeader('Access-Control-Allow-Oringin','*'); res.setHeader('Access-Control-Allow-Methods','GET,POST,OPTIONS'); res.setHeader('Access-Control-Allow-Headers','X-Requested-With,content-type,Authorization,accept'); if (req.method === 'OPTIONS'){ res.statusCode = 200; return res.end(); } else{ return next(); } }); 有什么build议么? 注:后端和前端不在同一个端口,我试图使它作为CROSS起源的资源。

使用intern与systemjs

我目前正在考虑将实习生整合到一个更大的技术堆栈中,似乎被卡住了。 大多数情况下,我跟着这篇文章,介绍如何用InterntestingTypeScript 。 我开发使用nodejs和angularScript打字机转换到ES5。 模块格式是systemjs (不幸的是,在这个环境中是必须的)。 在实习文档中提到了testing其他模块types的东西,但是如果可能的话,我不确定如何使其适应我的需求。 如果我尝试通过手动require($module)来绕过systemjs,intern会不停地通知我缺less必需的模块(模块的依赖关系)。 我目前的tsconfig-options: "compilerOptions": { "module": "System", "target": "ES5", "sourceMap": true, "noEmitOnError": false, "outDir": "src/scripts/js" } 我留下了实习生的示例configuration几乎没有改变,虽然我添加了angular度模块的正式angular度示例testing。 任何提示或帮助,将不胜感激

使用nodeJS上传时,文件被破坏

这是我的服务器代码 app.post('/tde/api/photo/:widgetId/:choosenFileName',function(req,res){ console.log("In file Upload.."); console.log(req.params.widgetId); console.log(req.params.choosenFileName); res.writeHead(200, { 'Content-Type': 'application/binary' }); var filedata = ''; req.setEncoding('binary'); req.on('data', function(chunk){ filedata+= chunk; }) req.on('end', function (chunk) { var dir = 'uploads/'+req.params.widgetId if (!fs.existsSync(dir)){ fs.mkdirSync(dir); console.log("directory created.."); } var fileName = req.params.choosenFileName; var widgetId = req.params.widgetId; fs.writeFile('uploads/'+widgetId+'/'+fileName, filedata, 'binary', function(err) { if (err) { return console.error(err); } […]

Angular没有从承诺的FS.readFile中获取数据

我正在尝试使用Angular服务来调用fs.readFile或fs.writeFile这取决于按下的button的types,以便了解节点和angular度许诺如何交互。 我所拥有的是读写文件,但是不会发回读取的数据,也不会为了解错误而抛出任何错误。 //HTML <button ng-click="rw('write')">WRITE FILE</button> <button ng-click="rw('read')">READ FILE</button> //angular angular.module('test', []) .controller('ctrl', function($scope, RWService){ $scope.rw = function(type){ RWService.rw(type) .then( function(res){ console.log('success'); }, function(err){ console.log('error'); }) }; }) .service('RWService',['$http', '$q', function($http, $q){ this.rw = function(type){ var promise = $http.get('./rw/' + type); var dfd = $q.defer(); promise.then( function(successResponse){ dfd.resolve(successResponse); }, function(errorResponse){ dfd.reject(errorResponse); } ); return dfd.promise; […]

Angular.js – 我需要devise2个应用程序还是只有一个?

我用Nginx定义了两个虚拟服务器来处理 营销的东西和用户authentication主域名www.example.com和 一旦用户被authentication,子域admin.example.com上的pipe理员应用程序 server { listen 8080; server_name example.com; root html; location / { index index.html index.htm; } server { listen 8080; server_name admin.example.local; root html/admin; location / { index index.html index.htm; } } 我想用一个Angular.js单页应用程序来处理营销内容,而用一个Angular.js多页面应用程序来pipe理这些pipe理员的东西。 可能吗 ? 我应该只devise2个应用程序还是1个ap?

从angular度到节点POST数据不工作

我正在使用angular度发送数据到节点服务器,但它不工作。 我无法在我的节点发布方法中看到我的发布数据(表单中的input值)。 我需要将这些数据保存在mongoDb中,但是我不知道为什么我看不到前端发送的POST值。 我无法通过console.log()在节点中查看我的表单数据。 有时候它会返回{},有时POST会被'morgan'debugging器在我使用时识别为OPTIONS req console.log(req.body.fname); 我的Html: <body ng-app="app" ng-controller="MyController"> <div id="login-page" class="row"> <div class="col s12 z-depth-6 card-panel"> <form ng-submit="postData();"> <div class="row" style="height: 90px;background-color:#00BFA5;margin: -12px -12px 15px -12px"> <h3 class="center-align">Register</h3> </div> <div class="row margin"> <div class="input-field col s12"> <i class="mdi-social-person prefix"></i> <input id="fname" name="fname" ng-model="formData.fname" type="text" class="validate"> <label for="fname" class="center-align">First Name</label> </div> </div> <div […]