Does anyone know how Dinamic could make a Slider with Nodejs - express - mongodb?

0

<div id="myCarousel" class="carousel slide" data-ride="carousel">
  <!-- Indicadores -->
  <ol class="carousel-indicators">
    <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
    <li data-target="#myCarousel" data-slide-to="1"></li>
    <li data-target="#myCarousel" data-slide-to="2"></li>
    <li data-target="#myCarousel" data-slide-to="3"></li>
  </ol>

  <!-- imgagen -->
  <div class="carousel-inner">
    <div class="item active">
      <img src="../images/slider/1.png" alt="imagen-slider">
    </div>
    <div class="item">
      <img src="../images/slider/2.png" alt="imagen-slider">
    </div>
    <div class="item">
      <img src="../images/slider/3.png" alt="imagen-slider">
    </div>
    <div class="item">
      <img src="../images/slider/4.png" alt="imagen-slider">
    </div>
  </div>
  <!-- flechas de control (izq. - der.)-->
  <a class="left carousel-control" href="#myCarousel" data-slide="prev">
    <span class="glyphicon glyphicon-chevron-left"></span>
    <span class="sr-only">Previous</span>
  </a>
  <a class="right carousel-control" href="#myCarousel" data-slide="next">
    <span class="glyphicon glyphicon-chevron-right"></span>
    <span class="sr-only">Next</span>
  </a>
</div>
    
asked by Duval Alcivar Demera 29.08.2018 в 02:09
source

1 answer

0

I really do not know what kind of problem the class active could present to you. Better said if it were my project I would do the following:

  • I create a class (or function) in javascript that builds me the complete component of the item of the image, that is, all this

    <div class="item active">
        <img src="../images/slider/1.png" alt="imagen-slider">
    </div>
    
  • would take the property as a variable src=../images/slider/algunaImagen.png .

  • This variable is the one I take as a reference to link it to the object (in this case the image) that I will bring from the database and insert all the components with their respective src dynamically with Javascript evidently.

  • I would only take into account to which component I add the class active which of course is also done from javascript to be dynamic.

  • I hope the idea helps you.

        
    answered by 29.08.2018 в 15:07