$anchorScroll equivalent in Angular2 for Same page anchor navigation

9,610 views
Skip to first unread message

Jeetendra Kumawat

unread,
Feb 11, 2016, 4:00:04 AM2/11/16
to AngularJS
Hi All,

I am learning Angular2 since a month. I have used angular2 router in my application and am using hash Location Strategy for Navigation in Angular app which is best suitable for my need.

Actually, I want to have anchor tag with href="#someDivID" for sub-navigation inside one page but each time it clicked angular2 Error pops up and ask for route which is not there.

I have found that in Angular1.0 there is $anchorScroll which works fine after setting Location.Hash.

Do we have any equivalent in Angular2 for $anchorScroll?

Please help!!

 

Günter Zöchbauer

unread,
Feb 12, 2016, 2:48:45 AM2/12/16
to AngularJS

Jeetendra Kumawat

unread,
Feb 12, 2016, 8:20:06 AM2/12/16
to AngularJS
Thank you Günter!! I will follow the Issue.

Benny Bottema

unread,
May 20, 2016, 4:33:44 PM5/20/16
to AngularJS
I recently published ng2-simple-page-scroll, a simple anchor jumping directive that works with routing and within routed views:

<a simplePageScroll href="#myanchor">Go there</a>

Or right after routing:

<a simplePageScroll [routerLink]="['Home']" href="#myanchor">Go there</a>

It does a simple instant jump, but it works. It's compatible with Angular2 rc1.

Michael Schreiber

unread,
Jun 14, 2016, 12:19:03 PM6/14/16
to AngularJS
Are there typings included with the npm install? 

I am having pathing issues on the import of the directive.

Thanks

Michael Schreiber

unread,
Jun 14, 2016, 2:39:35 PM6/14/16
to AngularJS
Got it working. Had pathing issues. 

Pallavi Darbhamulla

unread,
Aug 26, 2016, 7:48:15 PM8/26/16
to AngularJS
Hi Benny,
Could you please release the version with the fix for this ussue:

node_modules/ng2-simple-page-scroll/src/ng2-simple-page-scroll.directive.ts
(35,71): error TS2339: Property 'changes' does not exist on type 'Router'.

Thanks,
Pallavi

On Friday, May 20, 2016 at 2:33:44 PM UTC-6, Benny Bottema wrote:

Benny Bottema

unread,
Aug 27, 2016, 9:32:32 AM8/27/16
to ang...@googlegroups.com

--
You received this message because you are subscribed to a topic in the Google Groups "AngularJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/EwAbsf9MpBM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to angular+unsubscribe@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages