0

I have a slider with miniature of video and when a click on a miniature, whatever, a modal with the first video of my list was open, not with the video who correspond to the miniature I want to use ng-if to compare an id of a video with the miniature of the video in a slider, but i with what ? Can i use a syntax who what similar like data.id == data.miniature.id ? I really don't know ...

<div class="col-lg-5 col-md-5 col-sm-6 col-xs-12 contVideo">
        <div>
          <div class="video" ng-controller="videoCtrl">
            <slick class="carousel" infinite="true" settings="slickConfig">
            <div ng-repeat="data in video" class="contentVideo" ng-style="{'background-image':'url({{data.miniature}})'}">
              <a data-toggle="modal" data-target="#myModal">
                <img ng-src="images/index/video/BoutonPlay.png" alt="Play" />
              </a>
              <div class="descriptionVideo">
                <p>{{data.legende}}</p>
              </div>
            </div>
       </slick>
                 <div class="modal fade" id="myModal" ng-repeat="(key, data) in video" ng-if="data.id == ?">
              <div class="modal-dialog" role="document">
                <div class="modal-content">
                  <div class="modal-header">
                    <button ng-attr-type="button" class="close" data-dismiss="modal">x</button>
                  </div>
                  <div class="modal-body">
                 <video ng-src="{{data.src}}" controls="controls" width="550px" height="300px" poster="{{data.miniature}}" preload="metadata"></video>
               </div>
              </div>
              </div>
            </div>

          </div>
        </div>
      </div>
AtheistP3ace
  • 9,611
  • 12
  • 43
  • 43
WeelCodeur
  • 143
  • 2
  • 10

2 Answers2

0

Why not?))
*ngIf=data.id == data.miniature.id
If you data not on onInit, you can use elvis:) syntax.Here it is, protecting against a view render failure if value is null

data?.id == data?.miniature?.id
Dmitry Sobolevsky
  • 1,171
  • 6
  • 12
0

You can use ng-if like any other normal IF statement.

<div ng-if="data.id == 1 || data.string == 'string'">
   <p>Paragraph goes here</p>
</div>

As you can see in the example above you can include || or && into ng-if

Hope this helps.

Alex Ananjev
  • 269
  • 3
  • 16
  • but i don't know the id of the video, i can't put data.id == 1 because it's a slider and the video depend, if it's the first miniature the id of the video is one, but if it's the second it's 2 ... I want to select the video who was attached to the miniature – WeelCodeur Jan 12 '18 at 14:32
  • if you know the possible value of miniature you can write _ng-if="data.miniature.id == 1"_ , in this case if ID is 1 you can display/do appropriate content or action. – Alex Ananjev Jan 12 '18 at 14:37
  • @WeelCodeur is _id_ the same as _index_? You can reach the index with `$parent.$index` – Aleksey Solovey Jan 12 '18 at 14:38
  • Can i get the id of the miniature in te slide on which i click ? (it's the same of the video because it's the same index : : $scope.video = [ { "id" : 1, "legende": "title of the video", "src": "images/index/video/video.mp4", "miniature": "images/index/video/videoMiniature.png" }, – WeelCodeur Jan 12 '18 at 14:48
  • I think the question goes into a whole different thread now, I would need to see the code, preferably with a jsfiddle example. I would recommend raising another question on the forum, unless @AlekseySolovey knows how to help with that. – Alex Ananjev Jan 12 '18 at 14:54
  • @AlexAnanjev i ask this question to resolve my first problem, i explain my problem here : https://stackoverflow.com/questions/48202971/js-wrong-redirection-with-a-slider – WeelCodeur Jan 12 '18 at 14:57
  • @WeelCodeur if this answer helped you with your question, you would need to close this thread by selecting the appropriate answer, meanwhile I will take a look at the question you have asked before, many thanks – Alex Ananjev Jan 12 '18 at 15:01