javascript - mongoose syntax with user.id connecting to a form -


hi new mongoose , angular through ionic. trying build app , having problem it. have no idea if syntax mongoose right because still not working in front end user picks , answer , saves database

heres mongoose question.js

var express = require('express'); var router = express.router(); var mongoose = require('mongoose'); var question = require('../models/question.js'); var app = express();      // questions listing. questions/yourroute  router.get('/', function(req, res, next) {   question.find(function(err, questions){  if(err) return next(err);   res.json(questions);   });  });   router.post('/saved-questions', function(req, res){   var = date()  user.findbyid(user.id, function(err, user){  var newanswer1 = {     question: '58ccb991caf9756f8e1d8a6c',     answer_text: req.body.q1,     postdate:  }     });    user.users_answers.push(newanswer1);   //repeat q 2 , 3, push each time   user.save()    });   module.exports = router; 

and form in ionic.. don't know why not working, maybe how im putting in ionic form. there suppose slides of questions in ionic , each possible answer in ion check box

 <div id="questions" ng-controller="qcntrl">   <ion-content>  <ion-slide-box>  <ion-slide>  <div class="intro" ng-controller="popupctrl">     <h1 class="hidden">intro question</h1>     <h3>just need ask questions make app personalized you</h3>     <button class="button" value="next" ng-click="nextslide()">okay</button>      <button class="button2 button-positive" ng-click="popalert()">   why?      </button>     </div>    </ion-slide>       <ion-slide>   <div id="q1box">   <h2>{{questions[0].question_text}}</h2>  <ul>  <li data-ng-repeat="answer in answers1">  <ion-checkbox id="q1" ng-model="filter.users_answers">{{answer.label}}</ion-    checkbox> </li> </ul> <a href="#" ng-click="next()">next question</a> </div> </ion-slide>  

where have user.save(), try changing user.save , move }) that's before user.save , put after change user.save user.save

you editing user found user.findbyid(user.id, function(err, user){ , seems want save push made user.users_answers user.save should you


Comments

Popular posts from this blog

How to understand 2 main() functions after using uftrace to profile the C++ program? -

c# - Update a combobox from a presenter (MVP) -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -