replace .click() with ng-click not working -
i'm sure because i'm using wrong, i'm confused. started when convinced move angular site i'm building on using router. result, lot of jquery code stopped working.
for example have navigation line under slideshow endcap arrows , dots each slide. when click arrow, advances or moves on. can click on dot , slide. code:
$('#arrow-next').click(function() { var currentslide = $('.active-slide'); var nextslide = currentslide.next(); var currentdot = $('.active-dot'); var nextdot = currentdot.next(); if(nextslide.length === 0) { nextslide = $('.slide').first(); nextdot = $('.dot').first(); } currentslide.removeclass('active-slide').fadeout(600, function(){ nextslide.fadein(600).addclass('active-slide'); }); currentdot.removeclass('active-dot'); nextdot.addclass('active-dot'); }); // end clicking next arrow $('.arrow-prev').click(function() { var currentslide = $('.active-slide'); var prevslide = currentslide.prev(); var currentdot = $('.active-dot'); var prevdot = currentdot.prev(); if(prevslide.length === 0) { prevslide = $('.slide').last(); prevdot = $('.dot').last(); } currentslide.removeclass('active-slide').fadeout(600, function(){ prevslide.fadein(600).addclass('active-slide'); }); currentdot.removeclass('active-dot'); prevdot.addclass('active-dot'); }); // end click $('.dot').click(function() { var index = $('.dot').index($(this)); var currentslide = $('.active-slide'); var newslide = $('.slide').eq(index); var currentdot = $('.active-dot'); var newdot = $(this); currentslide.removeclass('active-slide').fadeout(600, function(){ newslide.fadein(600).addclass('active-slide'); }); currentdot.removeclass('active-dot'); newdot.addclass('active-dot'); }); // end click
i want turn these functions can call on ng-clck can't figure out how.
where ever using class dot, add ng-click html tag. should solve problem. convert click function scope function , send parameters ng-click. advisable not have dom manipulations in controller. have problems incase have write unit test cases same later. dom manipulation should carried out in directive.
Comments
Post a Comment