I've been trying to get my angular flexslider
to work the way I want it to. Right now it's being dynamically populated but the images take a second to load. It doesn't look very good. I would like it to fade in when everything is fully loaded. How can i do this? I can't get ngAnimate
or a callback working. I've tried a directive as well. I've even tried $timeout
and setting variables to true and false at the end of functions in my controller. Nothing has worked.
Here is my code thus far:
HTML:
<flex-slider hide-till-load ng-show="showImages" class="animate-if" slider-id="slider" flex-slide="image in imagePaths track by $index" animation="fade" animation-loop="false" sync="#carousel" slideshow="false" control-nav="false" prev-text="" next-text="" init-delay="100" start="loaded()">
<li>
<img ng-src="{{image.custom}}" alt="Luxury Resort Rental Image"/>
</li>
</flex-slider>
Notes: hide-till-load
was a directive I attempted with $timeout
and scope.$last
. Neither worked. showImages
is a variable I set in my controller at the end of certain functions. However, it's not waiting until the images are fully loaded so it's not working how I want it to.
Javascript:
//works but does not wait until images are fully loaded. Not what I want
$scope.loaded= function(){
console.log("this is after");
$timeout(function() {
$scope.showImages= true;
$scope.iconHide= true;
});
}
//doesn't work at all
resortModule.directive('hideTillLoad', function (){
return{
scope:false, //don't need a new scope
restrict: 'A', //Attribute type
link: function (scope, elements, arguments){
console.log(scope.$last);
if (scope.$last) {
console.log('page Is Ready!');
}
}
}
})