Hi rani,
You can use $anchorScroll.
Or you can use $window.scrollTo(x, y);
Where x is the pixel along the horizontal axis and y is the pixel along the vertical axis.
Check this example. Now please take its reference and correct your code.
HTML
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Scroll to Top of page AngularJS</title>
<style type="text/css">
.BottomCorner
{
position: fixed;
bottom: 0;
right: 0;
cursor: pointer;
background-color: #0090CB;
display: inline-block;
height: 40px;
width: 40px;
text-align: center;
font-size: 20pt;
line-height: 40px;
}
</style>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.8/angular.min.js"></script>
<script type="text/javascript">
var app = angular.module('MyApp', []);
app.controller('MyController', function ($scope, $window, $anchorScroll) {
// Scroll to Bottom of Page.
$window.scrollTo(300, 800);
$scope.ScrollTo = function () {
// Scroll to Top of Page.
$anchorScroll();
}
});
</script>
</head>
<body ng-app="MyApp" ng-controller="MyController">
This is sample text<br />This is sample text<br />This is sample text<br />This is sample text<br />
This is sample text<br />This is sample text<br />This is sample text<br />This is sample text<br />
This is sample text<br />This is sample text<br />This is sample text<br />This is sample text<br />
This is sample text<br />This is sample text<br />This is sample text<br />This is sample text<br />
This is sample text<br />This is sample text<br />This is sample text<br />This is sample text<br />
This is sample text<br />This is sample text<br />This is sample text<br />This is sample text<br />
This is sample text<br />This is sample text<br />This is sample text<br />This is sample text<br />
This is sample text<br />This is sample text<br />This is sample text<br />This is sample text<br />
This is sample text<br />This is sample text<br />This is sample text<br />This is sample text<br />
This is sample text<br />This is sample text<br />This is sample text<br />This is sample text<br />
This is sample text<br />This is sample text<br />This is sample text<br />This is sample text<br />
This is sample text<br />This is sample text<br />This is sample text<br />This is sample text<br />
This is sample text<br />This is sample text<br />This is sample text<br />This is sample text<br />
This is sample text<br />This is sample text<br />This is sample text<br />This is sample text<br />
<div class="BottomCorner">
<a href="javascript:;" ng-click="ScrollTo()">▲</a>
</div>
</body>
</html>
Demo