AngularJs and Bootstrab tiles - angularjs

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>

Related

ng-repeat with boootstrap toggle strange behavior

below is my code
<div class='loadMainDiv' ng-controller="loadCntrl">
<ul class='list-header' data-toggle="collapse" data-target='#{{schema.name}}' ng-repeat='schema in data'> {{schema.name}}
<!-- <li data-toggle="collapse" data-target='#{{schema.name}}'>{{schema.name}}
</li> -->
<div id='{{schema.name}}' class="collapse in ">
<ul ng-repeat="schemaEle in schema.value">
<li class='list-item' ng-click='setSelected(schemaEle.name,$index)'><span ng-class="(selectedEle==schemaEle.name) ? 'selectedLi' :''">{{schemaEle.name+""}}</span></li>
</ul>
</div>
</ul>
</div>
this is output i am getting
Fruit
Mango
Banana
Language
English
Spanish
the behavior i am looking for is when i click on Fruit the DIV should be shrink and if click again it should expand. This is happening correctly but even if i click on individual sublist element i am getting same behaviour.
look strange for me ? what could be the reason
<div ng-repeat='schema in data'>
<div class='list-header' data-toggle="collapse" data-target='#{{schema.name}}'>
{{schema.name}}
</div>
<div id='{{schema.name}}' class="collapse in ">
<ul ng-repeat="schemaEle in schema.value">
<li class='list-item' ng-click='setSelected(schemaEle.name,$index); event.preventDefault();'><span ng-class="(selectedEle==schemaEle.name) ? 'selectedLi' :''">{{schemaEle.name+""}}</span></li>
</ul>
</div>
</div>

Positioning ui-angular carousel controls

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.

Howcome my accordion is not collapsing? - identical one does work

http://plnkr.co/edit/xUuZyQTES83yccFRcc4K?p=preview
Check out my plunker that replicates my exact problem. I trimmed my code as much as I could.
I've also skimmed my code as much as I can.. and unfortunately I have not been able to find what is so significantly different between the first set of accordions and the second that is causing the first set to not work.
First set(not working):
<div ng-repeat="x in numOfMaps" class="{{x.count}}Details">
<li class="m2Details m3Details"><a data-toggle="collapse" dataTarget="#{{x.count}}toggleBuilding" href="#">Building<span class="caret"></span></a></li>
<ul id="{{x.count}}toggleBuilding" class="accordion-body {{x.buildingOpen}}">
<li ng-repeat="y in this[x.count + 'InfoBuilding']" class="{{y.linkclass}}"><img src="{{y.icon}}" width="15px" height="15px">{{y.name}}</li>
</ul>
</div>
<div ng-repeat="x in numOfMaps" class="{{x.count}}Details">
<li class="m2Details m3Details m4Details"><a data-toggle="collapse" dataTarget="#{{x.count}}toggleOffsite" href="#">Offsite<span class="caret"></span></a></li>
<ul id="{{x.count}}toggleOffsite" class="accordion-body {{x.offsiteOpen}}">
<li ng-repeat="y in this[x.count + 'InfoOffsite']" class="{{y.linkclass}}"><img src="{{y.icon}}" width="15px" height="15px">{{y.name}}</li>
</ul>
</div>
This code is wrapped in another ul tag and additional stuff within..but I doubt any of that is having an affect since it is all functioning fine otherwise but here is a skeleton replica:
<div>
<ul>
<li><img></li>
<li ng-repeat=""><a>{{text}}</a></li>
<li><a><span>Text</a></li>
///first set of code (above)
</ul>
</div>
Second set(working):
<ul ng-repeat="x in numOfMaps" class="buildingDropdown {{x.count}}Details {{locationsVisibility}}">
<a class="btn btn-primary btn-block" id="toggleHeader" data-toggle="collapse" data-target="#{{x.count}}LocationsList" href="#"><span>Locations</span><span class="caret"></span></a>
<ul id="{{x.count}}LocationsList" class="accordion-body collapse buildingListDropdown">
<a ng-repeat="y in this[x.count + 'InfoBuilding']" href="{{y.link}}" class="{{y.linkclass}}" ng-click="clickLinks(y.initialOut,y.initialIn,y.backIn,y.backOut,y.name)"><li>{{y.name}}</li></a>
<a ng-repeat="y in this[x.count + 'InfoOffsite']" href="{{y.link}}" class="{{y.linkclass}}" ng-click="clickLinks(y.initialOut,y.initialIn,y.backIn,y.backOut,y.name)"><li>{{y.name}}</li></a>
</ul>
</ul>
Anyone care to take a look? It's probably something small and embarrassing, like a "DOH!" moment. Much appreciated. :)
You're right - it's something small!
You have accidentally camel cased some of the data-target attributes:
<li class="m2Details m3Details">
<a data-toggle="collapse" dataTarget="#{{x.count}}toggleBuilding" href="#">
Building
<span class="caret"></span>
</a>
</li>
Note dataTarget should be data-target.

Incrementing in angular

I have json in my controller (will be moved) that is basically: id, questionName, answer.
I want to show each question in the code below. One question at a time. Upon clicking on the A links for yes/no I want the question to move on to the next.
I was hoping I could increment using "count" with an initial 0 which is the id relating to the json, and it would subsequently increase till the last question. This however doesn't seem to work; or at least my implementation doesn't.
I hope that's clear enough. It's hard to explain.
<div class="row" id="dropdown" ng-controller="testYourself">
<div id="q" class="cta1_content ugh" style="display:none;">
<div ng-repeat="data in quiz" ng-show="count==0" data-ng-init="count=0">
<h2 class="text-center">{{data.name}}</h2>
<div class="col-xs-6 col-md-3 col-md-offset-3 text-center yesno">
<a href="#" class="q" data-question="{{count}}" data-answer="1" ng-click="count=count+1">
<span class="cta_next"><i class="icon ion-checkmark-round"></i></span>
</a>
</div>
<div class="col-xs-6 col-md-3 text-center yesno">
<a href="#" class="q" data-question="{{count}}" data-answer="0" ng-click="count=count+1">
<span class="cta_next"><i class="icon ion-close-round"></i></span>
</a>
</div>
</div>
</div>
</div>
My controller looks like this:
app.controller('testYourself', ['$scope', function($scope) {
$scope.quiz = [
{id:0, name:"q1", answer: [{0: 'a', 1: 'b}], weight:25}
];
The id's are unnecessary to me, but added to try and do what I was trying. (I am 2 days new to Angular).
Thank you
UPDATE
------
<div id="q" class="cta1_content ugh" ng-controller="testYourself" data-ng-init="count=0">
<div ng-repeat="data in quiz" ng-show="data.id==count">
<h2 class="text-center">{{ data.name }} {{count}}</h2>
<div class="col-xs-6 col-md-3 col-md-offset-3 text-center yesno">
<a href="#" class="q" data-question="{{data.id}}" data-answer="1" ng-click="count=count+1">
<span class="cta_next"><i class="icon ion-checkmark-round"></i></span>
</a>
</div>
<div class="col-xs-6 col-md-3 text-center yesno">
<a href="#" class="q" data-question="{{data.id}}" data-answer="0" ng-click="count=count+1">
<span class="cta_next"><i class="icon ion-close-round"></i></span>
</a>
</div>
</div>
</div>
Well there are quit a number of things going on here.
Many syntax errors in your posted js code. So if that is pasted from your actual code, consider adding necessary braces, brackets, and quotes.
There is an inline style on #q. This means that none of the contents are visible. With angular, all you need is ng-show, and the library will take care of the rest. So get rid of that, and you should see question 1.
You probably want to put the ng-init on an element like #q. ng-repeat creates a new scope, so your count here is in the scope of the repeat rather than the scope of the controller (which is probably what you want).
Hope that helps.

bootstrap carousel does not work correctly using partial file

I am new to bootstrap and AngularJs. I am using bootstrap and Angular Js for my current application. When I use the bootstrap carousel directly inside the index page, the carousel's slide link are working absolutely perfect. But When I load the carousel markup through the partial files using ng-view, the slide links does not work correctly. It only works one time and then just don't work the next time. Where I am going wrong. I am pasting the code below:
<div class="corousal-container">
<div class="col-md-12">
<ul id="tabs" class="ops-tabs">
<li class="col-md-4 ops-list active">
<a href="#" class="ops-block">
<span class="header">Charts</span>
</a>
</li>
<li class="col-md-4 ops-list">
<a href="#" class="ops-block">
<span class="header">Graphs</span>
</a>
</li>
<li class="col-md-4 ops-list">
<a href="#" class="ops-block">
<span class="header">Reports</span>
</a>
</li>
</ul>
</div>
</div>
<div class="col-md-12">
<div data-ride="carousel" class="carousel slide" id="execView">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-slide-to="0" data-target="#execView" class="active"></li>
<li data-slide-to="1" data-target="#execView" class=""></li>
<li data-slide-to="2" data-target="#execView" class=""></li>
</ol>
<div class="carousel-inner">
<div class="item">
<div class="container" id="pie-chart1">
</div>
</div>
<div class="item">
<div class="container" id="pie-chart2">
</div>
</div>
<div class="item active">
<div class="container" id="pie-chart3">
<div class="carousel-caption">
<canvas class="canvas" id="canvas" style="width: 400px; height: 400px;" width="600" height="600"></canvas>
</div>
</div>
</div>
</div>
<a data-slide="prev" href="#execView" class="left carousel-control"><span class="fa fa-angle-left"></span></a>
<a data-slide="next" href="#execView" class="right carousel-control"><span class="fa fa-angle-right"></span></a>
</div>
</div>
If you are using ng-view then you need to create your bootstrap carousel after the html is loaded. You can do this in the onload method.
<div ng-view onload="viewLoaded()"></div>
$scope.viewLoaded=function(){
$('.carousel ').carousel()
}
Use angular Bootstrap directives for this.
http://angular-ui.github.io/bootstrap/

Resources