I have many items in a long list. How can my users go to (e.g. bookmark) a specific item by visiting mypage.html # the_item_id?
Actually, this can be when I use the built-in view [Example 1], but not when I use the partial view [Example 2]. Is there a mistake in the latter case, or should I use any workaround?
Thanks in advance!
Example 1: you can visit page.html # a100 to see element 100 ::
<!doctype html> <html ng-app> <head> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.min.js"></script> <script> function MainCtrl($scope){ $scope.items = []; for(var i=0; i<200; i++){$scope.items.push({id: i})} } </script> </head> <body ng-controller='MainCtrl'> <div> <ul> <li ng-repeat="i in items"><a id='a{{i.id}}'>{{i.id}}</a></li> </ul> </div> </body> </html>
Sample 2: CANNOT point to page2.html # a100 to see item 100, WHY? ::
<!doctype html> <html ng-app> <head> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.min.js"></script> <script> function MainCtrl($scope){ $scope.items = []; for(var i=0; i<200; i++){$scope.items.push({id: i})} } </script> </head> <body ng-controller='MainCtrl'> <div ng-include="'scroll_view.html'"></div> </body> </html>
And this is scroll_view.html needed for example 2 ::
<div> <ul> <li ng-repeat="i in items"><a id='a{{i.id}}'>{{i.id}}</a></li> </ul> </div>
source share