I'm trying to turn an existing jquery plugin into a directive to use in my angular app.
My html:
<div ng-controller="BoxController">
<ul class="bxslider" bx-slider="{mode: 'horizontal', pager: false, controls: true, minSlides: 1, maxSlides:4, slideWidth: 350, slideMargin:10, infiniteLoop: false, hideControlOnEnd: true}">
<li ng-repeat="obj in items track by $index">
<div class="item"><img ng-src="{{obj + $index}}" /></div>
</li>
</ul>
</div>
So my directive is bx-slider
or bxSlider
app.directive('bxSlider', function()
{
return {
restrict: 'A',
link: function(scope, element, attrs)
{
angular.element(element).bxSlider(scope.$eval(attrs.bxSlider));
}
}
});
What happens is I get a list of images in a bulleted list. The CSS is certainly getting applied however the actions of it being a carousel isn't working. It is supposed to be something like this:
http://bxslider.com/examples/carousel-dynamic-number-slides
However I get
http://dopserv1.dop.com/bxslider/
with no errors in the console or anything. If I do a console.log
on attrs.bxSlider
I see all the params I defined in the HTML above. What am I doing wrong here? I am including jQuery 1.10.2 above the angular include.