I have problem, I'm using $(document).ready() in Jquery, and now I want to modify it by using angular.element(document).ready()
This is my code Jquery:
$(document).ready(function () {
$(".bxslider").bxSlider({
mode: 'fade',
caption: true,
auto: true,
speed: 1000
});
});
This is my code in Angularjs:
angular.module('webApp')
.controller('clientCtrl', function($scope) {
$scope.init = function ()
{
angular.element(document).ready(function () {
$(".bxslider").bxSlider({
mode: 'fade',
caption: true,
auto: true,
speed: 1000
});
});
}
})
And this is code in Html:
<div class="our-clients" ng-controller="clientCtrl" ng-init="init()">
<ul class="bxslider">
<li>
<div class="col-md-2 col-sm-3 col-xs-4 client-logo">
<a href=""><img src="images/kfc.png" alt="kfc" class="grayscale-logo-client" /></a>
</div>
<div class="col-md-2 col-sm-3 col-xs-4 client-logo">
<a href=""><img src="images/pixel.png" alt="pixel" class="grayscale-logo-client" /></a>
</div>
<div class="col-md-2 col-sm-3 col-xs-4 client-logo">
<a href=""><img src="images/country.png" alt="country" class="grayscale-logo-client" /></a>
</div>
<div class="col-md-2 col-sm-3 col-xs-4 client-logo">
<a href=""><img src="images/covex.png" alt="covex" class="grayscale-logo-client" /></a>
</div>
<div class="col-md-2 col-sm-3 col-xs-4 client-logo">
<a href=""><img src="images/book.png" alt="book" class="grayscale-logo-client" /></a>
</div>
</li>
</ul>
My slider still works, but I got an error message: TypeError: Cannot read property 'childNodes' of undefined
Please give me a way to solve it.
readyevent fires then Angular does it things altering the DOM. You really should put this into a directive. Then there's no need for thereadyevent. It also give you a jquery object too.