Angularjs Scroll To Counter In Ng-repeat May 29, 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 JugaHow To Change Selected Attribute Via JavascriptHow To Export Javascript Json Info To Csv (on Client Side)?How To Render React Component Without Reactdom.render Function? Share You may like these postsSlow Rendering Of Html Table When Binding Json DataHow Do I Convert Local Time To Utc?Ng-show Not Working With Underscorejs's _.isnull But Works With Val === NullDynamic Background Image With Angular Js Ng-repeat Post a Comment for "Angularjs Scroll To Counter In Ng-repeat"
Post a Comment for "Angularjs Scroll To Counter In Ng-repeat"