I am using routes in AngularJS which displays a different view based on the parameter, i.e URL parameter provided. I have a view that displays a slick slider. Unfortunately, the slider is not being instantiated or ran when the new view is displayed. How can I have this javascript run when the new view is displayed? Do I need to create a new directive?
AngularJS:
angularApp.config(['$routeProvider',
function($routeProvider) {
$routeProvider.
when('/',
{
templateUrl:'/pages/default.html'
}).
when('/:params',
{
templateUrl: function(params){
params.param = params.params.replace(':', '');
return '/pages/'+params.param; }
});
}]);
Slick Slider JS:
$(window).load(function(){
$('.slickSlider').slick({
slidesToShow: 4,
arrows: true,
infinite: true,
autoplay: true,
slidesToScroll: 1
});