Reputation: 273
I'm trying to figure out how to use angular-scroll from this source on github:
https://github.com/durated/angular-scroll
I'm still very new to AngularJS and I think I'm having trouble reading in between the lines on this example. I've correctly downloaded angular-scroll using bower, have put it in my index.html, and have injected it as a dependency. What I'm unsure about now is how exactly to use it. If I had a JSFiddle for it I could get it quickly. All I want to do is scroll to an element using its id. I'm currently using $anchorScroll and it's working but I want something smoother.
Any help/examples would be greatly appreciated!
Upvotes: 3
Views: 2861
Reputation: 53
Providing you have followed the steps as you described above it is now a case of simply attaching the directive to the element:
<a href="#title" du-smooth-scroll>Scroll to top</a>
By default this will smooth scroll to the element with the corresponding ID:
<h1 id="title">I am the Scroll target</h1>
Source Code: https://github.com/oblador/angular-scroll/blob/master/example/index.html
Demo: http://oblador.github.io/angular-scroll/
Upvotes: 1