Smooth Anchor Scroll to div using Angularjs

Smooth Anchor Scroll to div using Angularjs

In this Post We Will Explain About is Smooth Anchor Scroll to div using Angularjs With Example and Demo.Welcome on – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to angular scroll to element without hash Example

In this post we will show you Best way to implement AngularJS – Smooth Anchor Scroll, hear for angularjs smooth scroll to anchor with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

External Include file

AngularJS is a simple JavaScript framework Include one type of the (library) based on a very user friedly popular software mvc based architecture menas called the MVC.

   <script src=""></script>


This is the main HTML view of our Simple Web Application. In here, we have init Base declared all our simple my this Example(angularjs smooth scroll to anchor) dependencies and the HTML Elements that we have created.

<div ng-app="liveApp">
<div id="liveDataContent" ng-controller="liveCtrl">
    <button ng-click="scrollGoToData('center_data')">Go to center_data</button><br/>
    <button ng-click="scrollGoToData('Last_data')">Go to Last_data</button>
<p>angular-scroll example,angularjs anchorscroll example,angularjs smooth scroll,angular smooth scroll demo,ngsmoothscroll example,anchorscroll yoffset,angular scroll to element without hash,$anchorscroll not working</p>

<p>angularjs scroll lazy load,angularjs scroll location,angularjs limitto scroll,angularjs scroll menu,angularjs scroll mobile,angularjs scroll magic,angularjs scroll modal,angularjs scroll mouse,angularjs scroll move,angularjs maintain scroll position,angularjs mouse scroll event,angular material scroll,angularjs move scroll to bottom,angularjs scroll not working</p>

<p>angularjs scroll ng-repeat,angularjs scroll navigation,angularjs ng-scroll,nicescroll angularjs,angularjs ng-scroll example,angularjs no scroll,angularjs ng-scroll event,angularjs native scroll,angularjs nested scroll,angularjs scroll to table row,angularjs scroll position</p>

<p>angularjs scroll pagination,angularjs scroll pagination example,angularjs scroll panel,angularjs scroll plugin,angularjs scroll performance,angularjs scroll position directive,angularjs scroll programmatically,angularjs scroll parallax,angularjs preserve scroll position,angularjs scroll refresh,angularjs scroll reset,angularjs route scroll to top,angularjs remember scroll position,angularjs retain scroll position,angularjs repeat scroll,angularjs routeprovider scroll</p>

<p>angularjs reverse scroll,angularjs scroll to right,angularjs scrollspy,angularjs scroll smooth,angularjs scroll baseSpeed,angularjs scroll stop,angular snap scroll,angularjs scroll style,angularjs scroll slow,angularjs scroll service,angularjs scroll select,angularjs scroll state,angularjs scroll to,angularjs scroll up,angularjs ui-scroll,angular ui scrollspy,angularjs ul scroll,angularjs ui-scroll example,angularjs infinite scroll</p>

<p>angularjs unbind scroll event,angularjs update scroll,angularjs unbind scroll,angularjs update scroll bar,angularjs scroll view,angularjs virtual scroll,vertical scrollbar angularjs,angularjs view scroll position,angularjs ng-view scroll,angularjs form validation scroll,angularjs ng-view scroll top,angularjs ui view scroll,angularjs table vertical scroll,angularjs scroll window,angularjs scroll watch,angularjs scroll without hash,angularjs window scrolltop,angularjs scroll within div,angularjs scroll width,angularjs scroll website,angularjs scroll with animation,angularjs window scroll not working,angularjs when-scroll-ends,angularjs scroll zoom</p>

<div id="center_data">Middle</div>

<p>angularjs scroll call function,angularjs continuous scroll,angularjs custom scroll,angularjs scroll div,angularjs scroll directive,angularjs scroll div to bottom,angularjs scroll down page,angularjs scroll down event,angularjs scroll div to top,angularjs scroll data</p>

<p>angularjs horizontal scroll table,angularjs horizontal scroll div,horizontal scrollbar angularjs,angularjs horizontal scroll event,angularjs handle scroll,angularjs scroll into view,angularjs scroll in table ng repeat</p>

<p>angularjs scroll load more,angularjs scroll listener,angularjs scroll list,angularjs scroll load,angularjs scroll left,angularjs scroll load data</p>

<p>angular scroll animation,angular scroll event,angular scroll to element,angular infinite scroll,angular2 infinite scroll,angular scroll</p>

<p></p><p>angularjs scroll,angularjs scrollbar,angularjs scroll event,angularjs scroll to a element,angularjs scroll load more,angularjs scroll event horizontal,angularjs scroll event for web application,angularjs scroll parent in reverse on drag,angularjs scrolltop</p>

<p>angularjs scroll to bottom of div,angularjs scroll to element on click,angularjs scroll event listener,angularjs infinite scroll,angularjs scroll,angularjs scroll to anchor</p>

<p>angularjs scroll event jsfiddle,angularjs infinite scroll json,angularjs infinite scroll without jquery,angularjs scroll without jquery,angularjs keep scroll position,angularjs keep scroll,angularjs scroll left right</p>

<p>angularjs scroll in div,angularjs scroll infinite,angularjs scroll images,angularjs scroll issue,angularjs infinite scroll example,angularjs infinite scroll table,angularjs infinite scroll pagination,angularjs infinite scroll ng-repeat,i scroll angularjs,angularjs jquery scroll,angularjs infinite scroll jsfiddle</p>

<p>angularjs get scroll position,angularjs get scroll position of element,angularjs grid scroll,angularjs get scroll height,angularjs scroll horizontal,angularjs scroll height,angularjs scroll hash,angularjs scroll header,angularjs horizontal scroll list</p>

<p>angularjs scroll fixed header,angularjs scroll focus,angularjs scroll factory,angularjs force scrolltop,angularjs follow scroll,angularjs force scroll,angularjs infinite scroll filter,angularjs table scroll fixed header,angularjs scroll glue,angularjs-scroll-glue example,angularjs scroll github,angularjs scroll glue not working,angularjs-scroll-glue download,angularjs-scroll-glue bower</p>

<p>angularjs scroll detection,angularjs scroll disable,angularjs scroll dropdown,angularjs scroll event listener,angularjs scroll event not firing,angularjs scroll element,angularjs scroll effect,angularjs scroll example,angularjs scroll end event,angularjs scroll event directive,angularjs scroll element to top,angularjs scroll end,angularjs scroll function,angularjs scroll fix</p>

<p>angularjs scroll body,angularjs scroll button,angularjs scroll back to top,angularjs scroll bottom div,angularjs scroll content,angularjs scroll container,angularjs scroll click,angularjs scroll carousel,angularjs scroll controller,angularjs scroll callback,angularjs scroll color</p>

<p>angularjs scroll to top on route change,angularjs scroll animation example,angularjs scroll animation,anchorscroll angularjs,angularjs scroll ajax,angularjs scroll arrow,angularjs scroll a div,angularjs scroll accordion,angularjs anchor scroll not working,angularjs auto scroll to top,angularjs auto scroll to bottom,angularjs scroll bottom,angularjs scrollbar style,angularjs scroll bottom event,angularjs scroll box</p>

<p>angularjs scroll to top,angularjs scroll event,angularjs scroll to bottom of div,angularjs scroll to bottom,angularjs scrollbar,angularjs scroll to bottom of page,angularjs scroll to top of div,angularjs scrolltop,angularjs scroll to top directive,angularjs scrollbar example,angularjs scroll,angularjs scroll to div,angularjs scroll to element</p>
    <a id="Last_data"></a> You're at the Last_data!


The simple angular controller works as a all the data of the mediator between HTML views and models.

Also Read :   Laravel Free charts and graphs for HTML5, JQuery and Javascript

var $scope, $location;
var liveApp = angular.module('liveApp', []);

liveApp.service('anchorSmoothScroll', function(){
    this.scrollTo = function(liveId) {

        var liveYData = currentYPosition();
        var EndYData = dataYPos(liveId);
        var allGap = EndYData > liveYData ? EndYData - liveYData : liveYData - EndYData;
        if (allGap < 100) {
            scrollTo(0, EndYData); return;
        var baseSpeed = Math.round(allGap / 100);
        if (baseSpeed >= 20) baseSpeed = 20;
        var phase = Math.round(allGap / 25);
        var itemY = EndYData > liveYData ? liveYData + phase : liveYData - phase;
        var counter = 0;
        if (EndYData > liveYData) {
            for ( var i=liveYData; i<EndYData; i+=phase ) {
                setTimeout("window.scrollTo(0, "+itemY+")", counter * baseSpeed);
                itemY += phase; if (itemY > EndYData) itemY = EndYData; counter++;
            } return;
        for ( var i=liveYData; i>EndYData; i-=phase ) {
            setTimeout("window.scrollTo(0, "+itemY+")", counter * baseSpeed);
            itemY -= phase; if (itemY < EndYData) itemY = EndYData; counter++;
        function currentYPosition() {
            if (self.pageYOffset) return self.pageYOffset;
            if (document.documentElement && document.documentElement.scrollTop)
                return document.documentElement.scrollTop;
            if (document.body.scrollTop) return document.body.scrollTop;
            return 0;
        function dataYPos(liveId) {
            var myval = document.getElementById(liveId);
            var y = myval.offsetTop;
            var allnode = myval;
            while (allnode.offsetParent && allnode.offsetParent != document.body) {
                allnode = allnode.offsetParent;
                y += allnode.offsetTop;
            } return y;


liveApp.controller('liveCtrl', function($scope, $location, anchorSmoothScroll) {
    $scope.scrollGoToData = function (liveId){


Last phase, we have add the Following CSS styles for our simple and our Custom styling.

Also Read :   convert string to number using javascript Example

#liveDataContent {
    height: 100%;
    overflow: auto;
  #Last_data {
    display: block;

angular-scroll example

You are Most welcome in my youtube Channel Please subscribe my channel. and give me FeedBack.
More Details……
Angularjs Example


I hope you have Got What is angularjs smooth scroll to anchor And how it works.I would Like to have FeedBack From My Blog( readers.Your Valuable FeedBack,Any Question,or any Comments about This Article( Are Most Always Welcome.