Angularjs Scroll To Counter In Ng-repeat March 03, 2024 Post a Comment Need to scroll to specific element in a list if $index == $scope.counter of ng-repeat. HTML: FIND TYPE ASolution 1: You've to write a directive for that and watch for counter to update. As soon as it updates, your directive finds the element by index (counter) and scrollTo it.Here is a demo: http://jsfiddle.net/ZdunA/1/ myApp.directive('scrollTo', function() { return { restrict: 'A', link: function(scope, element, attrs) { var$body = $('body'); scope.$watch('counter', function(newVal, oldVal) { if (newVal && newVal !== oldVal) { $body.scrollTop(element.find('li').eq(newVal).position().top) } }); } }; }); CopyBaca JugaAngularjs - Directive's Class Name Cannot Bring Into Inner TemplateIn Angular, On Selected Option Set Default Values For Other OptionsChanging The Format Of An Input Date With Angularjs Not Working As Expected Share You may like these postsAngular - Ng-change Not Firing When Ng-model Is ChangedAngularjs & D3 : Angular Directive For D3 Load Multiple TimesAngular Internet Routable Email Address ValidationJavascript: Shuffle 2d Array Post a Comment for "Angularjs Scroll To Counter In Ng-repeat"
Post a Comment for "Angularjs Scroll To Counter In Ng-repeat"