我在MongoDB中有一个集合作为数组返回到我的前端。现在,我的查询是获取具有特定category_Id的所有项目。一切都按预期回归。
问题:我需要能够将结果输入前端(angularJS),数组从结果中的特定点开始,而不是每次从0索引或第一个结果开始。
实施例: 查询返回数组中的结果; [0,1,2,3,4,... 500]。结果在视图中填充,ng-repeat为0,1,2等。例如,如何从[347]开始ng-repeat?
查看:
<div class="col m12" dir-paginate="material in scrollStuff | itemsPerPage: 1">
<div class="card">
<div class="card-content">
<h5 class="card-title activator grey-text text-darken-4">{{ material.material_name }}<i class="material-icons right">more_vert</i></h5>
</div>
<div class="card-image waves-effect waves-block waves-light">
<img class="activator" ng-src="http://marble.com/uploads/materials/{{material.material_id}}/1280X720/{{material.material_photo_name}}">
</div>
<div class="card-reveal" id="reveal">
<span class="card-title grey-text text-darken-4"><h3>{{ material.material_name }}</h3><i class="material-icons right">close</i></span>
<p><strong>Description: </strong>{{ material.material_description }}</p>
<p><strong>Other Names: </strong>{{ material.material_other_names }}</p>
<p><strong>Country of Origin ID: </strong>{{ material.material_country_of_origin }}</p>
</div>
</div>
</div>
查询:
app.get('/material/:id', (req, res) => {
db.collection('moreInfoPhotos').find({"material_category_id": req.params.id}).toArray(function(err, results) {
console.log(req.params.id);
res.json(results);
});
});