mean-stack

Unable to print the data fetched by the controller.js

帅比萌擦擦* 提交于 2019-12-12 01:14:45
问题 I am new to this and i am trying to make a dummy contact list. I have printed the log which fetches the data from mongodb and i can see the correct data in browser console,but when i try to print it in html file it doesn't display. Here are the snippets: controller.js var myApp = angular.module('myApp', []); myApp.controller('AppCtrl', ['$scope', '$http', function($scope, $http){ $http.get('/contactlist').then(function(response){ console.log("I got the response"); console.log(response); /

how to stop using livereload.js in my MEAN app

核能气质少年 提交于 2019-12-11 20:50:39
问题 I have moved my dev MEAN app from my laptop onto Azure. I have set off of grunt's livereload flags to false, but, livereload.js is still being loaded, and its absolutelly killing me! It take like 30 seconds(!) waiting for livereload.js Is there a way to get rid of it altogether? 回答1: Steps to fully remove livereload in your app if running in development mode: Disable it in gruntfile by giving options.livereload = false for your watch task. Uncomment the script request from your html file. In

UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): MongoError: failed to connect to server on first connect

懵懂的女人 提交于 2019-12-11 18:14:59
问题 I have an app developed using MEAN stack. I am getting the following error (node:4920) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): MongoError: failed to connect to server [ds047865.mongolab.com:47865] on first connect [Mon goError: connect ECONNREFUSED 130.211.211.211:47865] (node:4920) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a

MEAN Stack: post method is not reflecting in database

点点圈 提交于 2019-12-11 18:12:41
问题 I'm trying to pass some data through HTTP post method but it is not reflecting in the database. This is code. addJobList(jobitem) { let headers = new Headers(); headers.append('Content-Type','application/json'); var selected = { companyTitle : jobitem.company, jobTitle : jobitem.jobtitle, location : jobitem.location } console.log(selected); this.http.post('http://localhost:3000/api/appliedjobs', JSON.stringify(selected),{headers: headers}) .map(res => res.json()); } //getting jobs form back

Access API endpoints in MEANjs from server controller

耗尽温柔 提交于 2019-12-11 17:04:12
问题 so i have this problem i am working on 'following' feature in my application. What's important, i have two models: Follows and Notifications When I hit follow button in front-end I run function from follow.client.controller.js which POSTs to API endpoint /api/follows which corresponds to follow.server.controller.js and then update action on Follows model is performed - easy. AFAIK thats how it works (and it works for me). But in follows.server.controller.js I want also invoke post to API

MEAN : Serve File from GridFs

北战南征 提交于 2019-12-11 16:08:21
问题 I am using MEAN stack and I am trying to serve a file stored using Mongo GridFs. This is the code I have tried so far. exports.getFile = function(req, res) { var fileId = req.params.fileId; gfs.findOne({ _id: fileId }, function (err, file) { if (err) { res.status(500).send(err) } console.log('file meta', file); res.header("Content-Type", file.contentType); var readstream = gfs.createReadStream({ filename: file.filename }); //error handling, e.g. file does not exist readstream.on('error',

Angular: how to set input of time type to current time on initialization

久未见 提交于 2019-12-11 16:02:32
问题 I have created time and date input form with FormBuilder and created working html interface (create.component.html): <form [formGroup]="createForm" class="create-form"> <mat-form-field class="field-full-width"> <input matInput type="time" placeholder="Time of activity" formControlName="time" #time/> </mat-form-field> <mat-form-field class="field-full-width"> <input matInput [matDatepicker]="dp" formControlName="date" #date> <mat-datepicker-toggle matSuffix [for]="dp"></mat-datepicker-toggle>

unable hash the password in mean stack

若如初见. 提交于 2019-12-11 15:14:24
问题 This is the code from routes file. router.put('/reset/:token', function(req, res, next) { console.log('reseting the password'); User.findOne({resetPasswordToken:req.params.token}, function(err, user) { if(err) { return next(err); } if (!user) { return res.status(422).json({errors: [{msg: 'invalid reset token'}]}); } user.resetPasswordToken =''; user.resetPasswordExpires = ''; user.password = req.body.password; User.addUser(user, (err, user) => { if(err){ res.json({success: false, msg:

Angular/LocalStorage: Keep getting logged out on page refresh, despite setting/getting localStorage

。_饼干妹妹 提交于 2019-12-11 14:45:53
问题 I've been working on my first MEAN stack application. Currently, I am able to sign up new users and log them in. However, when I do either (login or sign up), I am unable to refresh the home page without getting logged out. I have successfully setting my localStorage, and can get it in my parent component, but the issue remains. I've been looking through lots of S.O. questions, but can't seem to nail it down. Here's my Login post route //LOGIN POST router.post('/login', (req, res) => { let

message: path is required

独自空忆成欢 提交于 2019-12-11 13:47:25
问题 Hi I'm trying to create a new subdocument via mongoose, but i'm getting the following messages when I execute the POST method in Postman: { "message": "Location validation failed", "name": "ValidationError", "errors": { "reviews.1.reviewText": { "message": "Path `reviewText` is required.", "name": "ValidatorError", "properties": { "type": "required", "message": "Path `{PATH}` is required.", "path": "reviewText" }, "kind": "required", "path": "reviewText" }, "reviews.1.rating": { "message":