Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Integrate Fancybox with AngularJs

I am just getting started with angularjs and I would like to know if it is possible to integrate fancybox into an angularjs controller so that there is the default fancybox loading animation shown between ajax requests.

Using the following code nothing happens and there are no console errors or messages.

If some example code could be provided in case where there is an alternative solution using fancybox.

Thanks.

Note: I have defined a div with ng-view inside my index.html file.

$scope.search = function () {

    $.fancybox.showLoading();

    MyApp.query({
        query: $scope.query
    }, function (value, responseHeaders) {

        $.fancybox.hideLoading();

    });
};
like image 890
Grant Avatar asked Sep 19 '26 03:09

Grant


1 Answers

You need to create directive to integrate Fancybox into your angular code. Look at a similar Lightbox directive created here. It can be seen in action here.

Coming to showing the loading animation on ajax request, using Fancybox for it would be not be correct as that is not its primary purpose. Google for how to do ajax spinner with angularjs. The basic idea is to implement request and response interceptor and show animation. One such example is present here

like image 190
Chandermani Avatar answered Sep 21 '26 16:09

Chandermani



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!