我正在做一个测验网络项目。这是
水疗中心
基于应用程序,使用angularjs,节点。js,mongodb。我将用户对象存储在mongodb中,如下所示。。。
{ "_id" : ObjectId("5ac11e238172b601087a6920"), "userid" : "lucy", "password" : "$2a$10$/o5ioD82//x5gWzweWQNI.8bBHSxEEj3AnqWXgoQXSltP.y5NFgUi", "questions" : [ { "qstn" : "b", "opt1" : "b", "opt2" : "b", "opt3" : "b", "opt4" : "b", "ans" : "b" }, { "qstn" : "j", "opt1" : "j", "opt2" : "j", "opt3" : "j", "opt4" : "j", "ans" : "j" }, { "qstn" : "hhhh", "opt1" : "hh", "opt2" : "hh", "opt3" : "hh", "opt4" : "hh", "ans" : "hh" } ], "__v" : 0 }
{ "_id" : ObjectId("5ac11e238172b601087a6920"), "userid" : "mani", "password" : "$2a$10$mGztF/S7hXyympOeunTiKOclTAKaTgBgzAkbsxIssFazwHxSq54um", "questions" : [ { "qstn" : "a", "opt1" : "b", "opt2" : "a", "opt3" : "a", "opt4" : "a", "ans" : "a" }, { "qstn" : "jj", "opt1" : "jj", "opt2" : "jj", "opt3" : "jj", "opt4" : "jj", "ans" : "jj" }, { "qstn" : "hhhh", "opt1" : "hh", "opt2" : "hh", "opt3" : "hh", "opt4" : "hh", "ans" : "hh" } ], "__v" : 0 }
当我询问时
fetchQuestions(request,response){
User.find({},function(err,user){
console.log(user);
}).select('questions -_id').limit(10);
}
我在服务器控制台上得到了这个结果
[
{ questions: [ [Object], [Object], [Object] ] },
{ questions: [ [Object], [Object], [Object] ] }
]
我的测试。html,用于打印问题及其选项
<div>
<h1>{{qstn}}</h1>
<input type="checkbox">
<h1 ng-repeat="">{{opt1}}</h1><br>
<input type="checkbox">
<h1 ng-repeat="">{{opt2}}</h1><br>
<input type="checkbox">
<h1 ng-repeat="">{{opt3}}</h1><br>
<input type="checkbox">
<h1 ng-repeat="">{{opt4}}</h1>
知道如何在网页上的数组中打印这些问题吗
如何应用
ng重复
打印问题及其选项