Positioning ui-angular carousel controls - angularjs

I am creating a carousel that displays images with some meta data. On md and lg screens I want the meta data to appear to the right, and on smaller screens I want it below the image, which is working fine using col-md-8 / col-md-4
Here is my carousel code:
<uib-carousel active="active" interval="0" no-wrap="noWrapSlides" template-url="/Scripts/MainClient/views/cwCarouselTemplate.html" style="height:100%">
<div uib-slide ng-repeat="slide in slides track by slide.id" index="slide.id">
<div class="row">
<div class="col-md-8 " ng-style="{height: hackheight}" id="img-div">
<div style="padding:10px; height:100%;" class="black-bkgd">
<span class="helper"></span><img class="img-responsive " ng-src="{{slide.image}}" style="vertical-align:middle; display:inline-block">
</div>
</div>
<div class="col-md-4">
Here's where the meta data goes go!
<h4>Slide {{slide.id}}</h4>
<p>{{slide.text}}</p>
</div>
</div>
</div>
</uib-carousel>
The problem I have is regarding the right hand control - it is positioned to the right of the whole carousel, and I want it right relative to the col-md-8 div (so it appears over the right hand side of the image, not over the meta data). It works if I set right to be 34% on the control, but this then doesn't work on xs/sm screens (the control is in the middle of the image).
I can get it to the right position on either xs/sm screens (with right:0) OR on md/lg screens (with right:34%) but not on all screens at the same time!
One idea I had is to add a <span class="hidden-xs hidden-sm" style="width:34%"></span> to the right to push the control over on larger screens but I can't get it to work - the span just stacks with the carousel control.
Here's the template I'm using:
<div class="carousel">
<div class="carousel-inner" ng-transclude></div>
<a role="button" href class="left carousel-control" ng-click="prev()" ng-class="{ disabled: isPrevDisabled() }" ng-show="slides.length > 1">
<span aria-hidden="true" class="glyphicon glyphicon-chevron-left"></span>
<span class="sr-only">previous</span>
</a>
<a role="button" href class="right carousel-control" ng-click="next()" ng-class="{ disabled: isNextDisabled() }" ng-show="slides.length > 1">
<span aria-hidden="true" class="glyphicon glyphicon-chevron-right"></span>
<span class="sr-only">next</span>
</a>
<!--
<ol class="carousel-indicators" ng-show="slides.length > 1">
<li ng-repeat="slide in slides | orderBy:indexOfSlide track by $index" ng-class="{ active: isActive(slide) }" ng-click="select(slide)">
<span class="sr-only">slide {{ $index + 1 }} of {{ slides.length }}<span ng-if="isActive(slide)">, currently active</span></span>
</li>
</ol>
-->
</div>
Many thanks for any help

You could wrap your buttons in a absolute positioned col-md-8 to achieve the result.
If the element height remains an issue, you could provide a plunkr of your code, so we can look into that.

Related

change id name of carousel by dynamically in angularjs

I have using carousel in my AngularJS App. I want change id of carousel each iteration but it is not working Please tell what did wrong?
<div ng-repeat="data in details">
<div class="carousel" id="{{data._id}}" style=" width: 290px;
max-width: 100% ;
height: 250px;">
<div class="carousel-inner">
<div class="item" ng-class="{active:!$index}" ng-repeat="photo in data.photos">
{{$index}}
<a target="_blank" ui-sref="PhotoUpload">
<img src="{{ photo }}" style=" width: 290px;
max-width: 100% ;
height: 250px;">
</a>
</div>
</div>
<a class="left carousel-control" data-target="#{{data._id}}" ng-non-bindable data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" data-target="#{{data._id}}" ng-non-bindable data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
First carousel image slide are working but after that second carousel images are not working if i click prev and next button first carousel images changing. but second images
Please help me.
I usually handle dynamic id values like this:
[attr.id]="data._id"
and for data-target
[attr.data-target]="'#' + data._id"
There must be possibilities your IDs are same for all elements. Please append {{$index}} within ID.
Try below snippet
id="{{data._id}}_{{$index}}"

Bootstrap carousel in ng-repeat

I have problem with Bootstrap carousel in ng-repeat, because images are not load one by one if carousel changes, but all images are load all at onece. I found similar questions in stackoverflow, but in my case I loading data from database (not use $scope)
<div class="container">
<div class="carousel slide" id="myCarousel">
<div class="carousel-inner">
<div class="item active">
<div class="row">
<div class="col-xs-3" ng-repeat="product in main.products"><img ng-src="../../uploads/{{ product.imagePath }}" class="img-responsive"></div>
</div>
</div>
<div class="item">
<div class="row">
<div class="col-xs-3" ng-repeat="product in main.products"><img ng-src="../../uploads/{{ product.imagePath }}" class="img-responsive"></div>
</div>
</div>
</div>
<a class="left carousel-control" href="#myCarousel" data-slide="prev"><i class="glyphicon glyphicon-chevron-left"></i></a>
<a class="right carousel-control" href="#myCarousel" data-slide="next"><i class="glyphicon glyphicon-chevron-right"></i></a>
</div>
</div>
The issue is that you are repeating all of your images inside an item of the carousel. A carousel item is defined by the "item" class. If you want a single image to displayed at once then repeat the items like so:
<div class="container">
<div class="carousel slide" id="myCarousel">
<div class="carousel-inner">
<!-- add the `active` class to the first item with one-time binding (if $index is 0) -->
<div class="item {{::($index === 0 ? 'active' : '')}}" ng-repeat="product in main.products track by $index">
<div class="row">
<div class="col-xs-3"><img ng-src="../../uploads/{{ product.imagePath }}" class="img-responsive"></div>
</div>
</div>
<a class="left carousel-control" href="#myCarousel" data-slide="prev"><i class="glyphicon glyphicon-chevron-left"></i></a>
<a class="right carousel-control" href="#myCarousel" data-slide="next"><i class="glyphicon glyphicon-chevron-right"></i></a>
</div>
</div>
</div>

Bootstrap carousel-control not working properly in Angular-Seed project

I have added Bootstrap in Angular-Seed project. The carousel-indicators are working fine but there is problem with the Prev/Next button.
On clicking Prev button, it switches to 3rd image & stays on it even if you click prev again. On clicking Next button, it switches to 2nd image & stays on it.
Tried replacing JQuery/Bootstrap with the CDN links but their versions is not the issue.
Here is the carousel I'm using:-
<div id="carousel" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#carousel" data-slide-to="0" class="active"></li>
<li data-target="#carousel" data-slide-to="1"></li>
<li data-target="#carousel" data-slide-to="2"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item active">
<img src="http://lorempixel.com/1500/600/abstract/1" alt="Slide 1" />
</div>
<div class="item">
<img src="http://lorempixel.com/1500/600/abstract/2" alt="Slide 2" />
</div>
<div class="item">
<img src="http://lorempixel.com/1500/600/abstract/3" alt="Slide 3" />
</div>
</div>
<!-- Left and right controls -->
<a href="#carousel" class="left carousel-control" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
</a>
<a href="#carousel" class="right carousel-control" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
</a>
</div>

ng-class or ng-style directive not working in ui bootstrap carousel

I am using UI Bootstrap Carousel and need to do some customization in it so that user have access of configuring options such as text color, navigation show/hide, etc....
For this i have used their carousel html template and added some ng-class for display block/none and some other ng-style but those are not working and do not have any effect over the same.
These are working fine if i am using the same on page where carousel markup written.
Refer to plunker to replicate issue
Carousel Plunker
Template HTML
<div ng-mouseenter="pause()" ng-mouseleave="play()" class="carousel" ng-swipe-right="prev()" ng-swipe-left="next()">
<div class="carousel-inner" ng-transclude></div>
<a role="button" href class="left carousel-control" ng-click="prev()" ng-show="slides.length > 1" ng-class="{'dispNone': carousel.arrow}">
<span aria-hidden="true" class="glyphicon glyphicon-chevron-left"></span>
<span class="sr-only">previous</span>
</a>
<a role="button" href class="right carousel-control" ng-click="next()" ng-show="slides.length > 1" ng-class="{'dispNone': carousel.arrow}">
<span aria-hidden="true" class="glyphicon glyphicon-chevron-right"></span>
<span class="sr-only">next</span>
</a>
<ol class="carousel-indicators" ng-show="slides.length > 1">
<li ng-repeat="slide in slides | orderBy:indexOfSlide track by $index" ng-class="{ active: isActive(slide) }" ng-click="select(slide)">
<span class="sr-only">slide {{ $index + 1 }} of {{ slides.length }}<span ng-if="isActive(slide)">, currently active</span></span>
</li>
</ol>
</div>
You can use $parent in the template as you are having different scopes. Like
$parent.navArrow

AngularJs and Bootstrab tiles

I am trying to display equal containers with image (that can be submitted with a different size, but resized to a fix size when displayed), and some content (title description, etc) -- similar to the Kickstarter's tiles of projects (https://www.kickstarter.com/discover/categories/technology?ref=discover_index). I tried columns, tables, container, but looks like I am missing something, because it doesn't want to display equal tiles :(((( HELP!
Here is my last "try"
<ul ng-repeat="project in projects" class="col-md-4 col-l-3 col-xl-2" id="wrap">
<a href="project.html?={{project.objectId}}" id="projectText">
<li><img class="img-responsive" src="{{project.image.url}}"></li>
<li>{{project.title}}</li>
<li>{{project.blurb}}</li>
<li>{{project.likes || 0}}</li>
<li><span id="hover" class="glyphicon glyphicon-thumbs-up" ng-click="incrementLikes(project, 1)"></span></li>
</a>
</ul>
I did a quick test and it looks as though you can have col-*-x tags that add up to more than 12, in which case this will work
<div class="row">
<div ng-repeat="project in projects">
<div class="col-md-4 col-l-3 col-xl-2">
<ul>
<a href="project.html?={{project.objectId}}" id="projectText">
<li><img class="img-responsive" src="{{project.image.url}}"></li>
<li>{{project.title}}</li>
<li>{{project.blurb}}</li>
<li>{{project.likes || 0}}</li>
<li><span id="hover" class="glyphicon glyphicon-thumbs-up" ng-click="incrementLikes(project, 1)"></span></li>
</a>
</ul>
</div>
</div>
</div>

Resources