0

Currently What I want to do is paginate all the data that has been successfully found by mongoose.

For example

route.js

app.get('/getProducts', function(req, res) {
   Product.find({}, function(err, products) {
       res.render('index');
   });
});

Assume that I have successfully find all the data.

index.ejs

   <% for(var i=0; i < products.length; i++)  {%>
     <%= products[i].name %>
    <% } %>

    <ul class="pagination">
    <li>
      <a href="#" aria-label="Previous">
        <span aria-hidden="true">&laquo;</span>
      </a>
    </li>
    <li><a href="#">1</a></li>
    <li><a href="#">2</a></li>
    <li><a href="#">3</a></li>
    <li><a href="#">4</a></li>
    <li><a href="#">5</a></li>
    <li>
      <a href="#" aria-label="Next">
        <span aria-hidden="true">&raquo;</span>
      </a>
    </li>
  </ul>

How do I use bootstrap pagination to paginate the data ?

Jack Moscovi
  • 2,195
  • 7
  • 30
  • 49
  • Possible duplicate of [How to paginate with Mongoose in Node.js?](http://stackoverflow.com/questions/5539955/how-to-paginate-with-mongoose-in-node-js) – Scott Stensland Dec 23 '15 at 21:13

2 Answers2

0
  <ul class="pagination">
    <li><a data-toggle="tab" href="#tab1">1</a></li>
    <li ><a data-toggle="tab" href="#tab2">2</a></li>
    <li><a data-toggle="tab" href="#tab3">3</a></li>
  </ul>
</div>
   <div id="tabcont" class="tab-content">
   <div id="tab1" class="tab-pane">name1</div>
   <div id="tab2" class="tab-pane">name2</div>
   <div id="tab3" class="tab-pane">name3</div>

</div>

try something like this

olszamix
  • 63
  • 9
0

pagination code will comes in frontend, you need to provide link for next page in html a href tag. You can refer Bootstrap Pagination tutorial for bootstrap pagination in detail.

FOD
  • 97
  • 1
  • 5