1

I want to be able to use routes like an anchor tag.

For example, say I had a category page with a list of products.

I wish to set the route ....../category/shoes to go to the top of the page,

And ....../category/shoes/air-max to scroll to the shoe on the same page that is dynamically loaded within a ng-repeat block.

Essentially, the page should emulate the behavior of a static page where:

  • /shoes.html will go to the top of the page
  • /shoes.html/#air-max will go to the anchor

the difference being that it is an angular app and the data is dynamically loaded.

jvperrin
  • 3,368
  • 1
  • 23
  • 33
zcaudate
  • 13,998
  • 7
  • 64
  • 124
  • yes. I'm using ng-view... see updated comments – zcaudate Mar 25 '13 at 23:23
  • 1
    Duplicate of [How to handle anchor hash linking in AngularJS](http://stackoverflow.com/questions/14712223/how-to-handle-anchor-hash-linking-in-angularjs). – Stewie Mar 26 '13 at 13:19
  • It is slightly different. They are using hand written anchors. I wish to scroll to anchors generated using Ng-repeat – zcaudate Mar 27 '13 at 21:19

1 Answers1

0

You may use $index inside your ng-repeat directive, so that each item as a unique index.

<ul ng-repeat="item in array">
  <li id="{{$index}}><li>
</ul>
Max Hoffmann
  • 2,957
  • 1
  • 17
  • 13