Skip to content

Instantly share code, notes, and snippets.

@vanessasoutoc
Forked from lazarofl/app.js
Last active August 29, 2015 14:08
Show Gist options
  • Save vanessasoutoc/41b0c44cdbee5381ea2f to your computer and use it in GitHub Desktop.
Save vanessasoutoc/41b0c44cdbee5381ea2f to your computer and use it in GitHub Desktop.
var app = angular.module('app', []);
app.controller("ListagemController", function($scope){
$scope.itens = [];
for (var i = 1; i <= 16; i++) {
$scope.itens.push({text: i});
};
})
app.directive('owlcarousel',function(){
var linker = function(scope,element,attr){
//carrega o carrosel
var loadCarousel = function(){
element.owlCarousel({
items : 10, //10 items above 1000px browser width
itemsDesktop : [1000,5], //5 items between 1000px and 901px
itemsDesktopSmall : [900,3], // 3 items betweem 900px and 601px
itemsTablet: [600,2], //2 items between 600 and 0;
itemsMobile : false // itemsMobile disabled - inherit from itemsTablet option
});
}
//aplica as ações para o carrosel
var loadCarouselActions = function(){
angular.element(".owlcarousel_next").click(function(){
element.trigger('owl.next');
})
angular.element(".owlcarousel_prev").click(function(){
element.trigger('owl.prev');
})
angular.element(".owlcarousel_play").click(function(){
element.trigger('owl.play',1000);
})
angular.element(".owlcarousel_stop").click(function(){
element.trigger('owl.stop');
})
}
//toda vez que adicionar ou remover um item da lista ele carrega o carrosel novamente
scope.$watch("itens", function(value) {
loadCarousel(element);
})
//inicia o carrosel
loadCarouselActions();
}
return{
restrict : "A",
link: linker
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment