简体   繁体   English

需要呈现MongoDB查询返回结果的特定索引/位置

[英]Need to render specific index/location of returned results from MongoDB query

Using AngularJS and MognoDB, is it possible to query the database, return the results, and then render the results in an angular view, BUT AT A SPECIFIC INDEX/LOCATION OF THE RETURNED DATA? 使用AngularJS和MognoDB,是否可以查询数据库,返回结果,然后将结果呈现在角度视图中,但要以返回数据的特定索引/位置为准?

NOTE: OBJECTS ARE RETURNED IN ARRAY... 注意:对象以阵列形式返回...

For example: 例如:

User clicks an <a> tag with ui-sref leading into View2 from View1. 用户单击带有ui-sref的<a>标签,从View1导入View2。 URL triggers query to MongoDB, returning 500 results. URL触发对MongoDB的查询,返回500个结果。 In View2, I need to render the results in a pagination format (already completed), but have the pagination START at the specific result that the <a> tag was on. 在View2中,我需要以分页格式(已经完成)呈现结果,但是要在<a>标记处于打开状态的特定结果上进行分页START。

PROBLEM: The results are returned and the View2 is rendered, but the results START at the beginning of the returned list, rather then at the specific result that was clicked from View1. 问题:返回结果并呈现View2,但是结果从返回列表的开头开始,而不是从View1单击的特定结果开始。

<div class="col m3" dir-paginate="material in graniteStuff | itemsPerPage: 20">
          <a ui-sref="material({id: material.material_category_id})"><div class="card">
            <div class="card-image small">
                <img ng-src="http://...">
            </div>
            <div class="card-content" id="color">
              <p>{{ material.material_name }}</p>
              <p>{{ material.material_country_of_origin }}</p> 
            </div>
            </div>
          </a>
        </div>

I'm passing the id as a parameter through the ui-sref to the query, but I need to ALSO pass the name of the material as a parameter, or somehow BEGIN the returned results at that specific location. 我通过ui-sref将id作为参数传递给查询,但是我还需要将材料名称作为参数传递,或者以某种方式在该特定位置开始返回结果。

Your search query needs to take the pageindex and pagesize and return a subset of the total results, along with the number of pages given the pagesize. 您的搜索查询需要使用pageindex和pagesize并返回总结果的子集,以及给出该pagesize的页面数。

Then you can render the paging elements, set the 'active' pager button and only render the results for that page. 然后,您可以呈现分页元素,设置“活动”寻呼机按钮,然后仅呈现该页面的结果。

.skip(pageindex * pagesize).limit(pagesize) // pageindex is 0 based

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM