0

I am making single page website in which as soon as you click the tab it navigates to the respective div with scrolling. I found scrollTo jquery function for that. But my question is , is it possible to achieve the same effect with angularjs or is it possible to embed jquery inside angular code?

Mistalis
  • 17,793
  • 13
  • 73
  • 97
Mrugesh
  • 4,381
  • 8
  • 42
  • 84
  • Did you check this? https://docs.angularjs.org/api/ng/service/$anchorScroll – mxr7350 May 17 '17 at 12:56
  • 1
    possible duplicate http://stackoverflow.com/questions/17284005/scrollto-function-in-angularjs – Edwin May 17 '17 at 12:56
  • 2
    Possible duplicate of [ScrollTo function in AngularJS](http://stackoverflow.com/questions/17284005/scrollto-function-in-angularjs) – urbz May 17 '17 at 12:56

1 Answers1

1

An alternative to the scrollTo jQuery function in Angular is the $anchorScroll service.

For example, the following code will scroll to the first element with id="myElementId".

$location.hash('myElementId');
$anchorScroll();

Here is a demo Plunker

Mistalis
  • 17,793
  • 13
  • 73
  • 97
  • but how to change the tabs when the page is scrolling in angular js? – Mrugesh May 17 '17 at 13:02
  • @Mrugesh What do you mean by "changing the tab"? – Mistalis May 17 '17 at 13:08
  • means, suppose I have three clickable tabs "x","y" and "z" .So as soon as I click "x" it should scroll to the divs related to x or when I automatically scroll to the div connected with x , it should show x highlighted – Mrugesh May 17 '17 at 14:13