Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding <div> in middle of ng-repeat using $index - Bootsrap container

I am tring to output <div> in middle of ng-repeat using $index== - however the Banner <div> is within the parent container so its not going accross the full width of the screen. I have tried using the class="container-fluid" on the Banner, but its making it even smaller. Is there any way to break out of the parent container at all (just for that one div, in the middle of the ng-repeat) to make the Banner full width?

This is how I would like it to look (for visual purposes only, need div's to be output using the ng-repeat): Plunker-1

And this is how it currently looks: Plunker-2

like image 630
James P Avatar asked Dec 04 '25 07:12

James P


2 Answers

Here is the solution : https://plnkr.co/edit/pYO1G8M3jIDXHrRSE4YE?p=preview


You do not need container-fluid to achieve what you intend to.


 <div class="col-md-12" id="Banner" ng-if="$index==8">

               <div class="well well-sm text-center">
                  Banner

              </div>
 </div>
like image 75
Kriti Agarwal Avatar answered Dec 07 '25 03:12

Kriti Agarwal


You're close, try this:

<div id="content">
  <div class="container" ng-controller="MainController">

  <h1>Hello Plunker!</h1>

    <div ng-class="$index === 8 ? 'col-md-12' : 'col-md-3'" ng-repeat="item in Data">
      <div class="container-fluid" id="Banner" ng-if="$index === 8">
        <div class="well well-sm text-center">
          Banner
        </div>
      </div>
      <div class="well active" ng-if="$index !== 8">
        <h3>{{item}}</h3>
      </div>
    </div>
  </div>
</div>
like image 28
Rob J Avatar answered Dec 07 '25 05:12

Rob J



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!