bxslider directive throwing error `Uncaught TypeError: Cannot read property 'indexOf' of undefined`

大城市里の小女人 提交于 2019-12-22 05:26:08

问题


I am using angularjs in my application where I have created a directive for bxslider. Below is code of directive:

angular.module('sbAdminApp')
.directive('bxSlider', function(){
    return{
        restrict: "A",
        require: "ngModel",
        link: function(scope, element, attrs, ctrl){
            element.ready(function(){
                $($(element[0])).bxSlider({
                    maxSlides:1,
                    auto:true,
                    controls:false,
                    pager:true
                });
            })
        }
    }
})

Above I am using like this $($(element[0])).bxSlider({ after ready function as I search for a problem where bxslider should work with ng-repeat and found this solution after which bxslider is working but sometimes images doesn't load and I can see this error always.

Uncaught TypeError: Cannot read property 'indexOf' of undefined


回答1:


Finally i got the answer after so many searches

This is not a angularjs error this is a jquery version compatibility with bxslider.

Issue is arised by jQuery .load() function.

In bxslider.js file find .load() function's code line. It was used only 1 time in bxslider.js.

From

$(this).load();

To

$(this).trigger('load');

Thanks to kkakkurt for this great solution https://stackoverflow.com/a/38562965/4119808



来源:https://stackoverflow.com/questions/38911759/bxslider-directive-throwing-error-uncaught-typeerror-cannot-read-property-ind

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!