Note: I still haven't solved this. This post seems to describe a solution to my problem since I'm using
ngRoute
and am on a newer version of Angular, but I couldn't make her solution work: https://mcmap.net/q/76887/-how-to-handle-anchor-hash-linking-in-angularjs
On my single page app: https://kylevassella.github.io/
I'm trying to link my nav buttons to hash links on a different view. I've been using the accepted answer here for help: How to handle anchor hash linking in AngularJS
But I'm having trouble implementing ($anchorScroll
) on my site.
To see what I'm talking about:
- My Plunker: https://plnkr.co/edit/fgTG7j?p=info Make the preview window wide enough so the nav menu
('Home Portfolio Contact') appears at the top.
Scroll down to ‘Projects’, click ‘Project 1’. This opens a new view &
ng-show
enables a different nav bar (which looks the same as the old. Look below<section ng-show="showPortfolioHeader">
inindex.html
for these nav anchors).From here I want ‘Portfolio’ & ‘Contact’ to link to the #portfolio & #contact hash link ID's in my
views/home.html
view. But they only take me to the correct route (views/home.html
), not to their respective scroll points on the page.
NOTE: On Plunker, these don't even link to the correct route, they bring me to a 404. That's not the problem - on my local machine this part works fine. My problem is that once I get to theviews/home.html
view, the browser isn't scrolling to the hash link.
ng-show
,ng-hide
nav blocks in question. – Bivalve