In the process of developing an Angular application, I have created a basic CMS-style app. Initially, I managed to navigate to pages without deep linking using the following code snippet:
<li ng-repeat="page in pages"><a href="#" ng-click="select(page)">{{page.linktext}}</a></li>
The corresponding controller function looked like this:
$scope.select = function(selected){
$scope.currentPage = selected;
};
After implementing deep linking into my app, the HTML now looks like this:
<li ng-repeat="page in pages"><a href="#/pages/{{page.linktext}}">{{page.linktext}}</a></li>
A route provider is used to capture the pageId from the URL.
In the controller, I am now using:
$scope.currentPage = $routeParams.pageId;
It has become evident that setting currentPage to the id and not the object is causing issues. How can I select the object associated with that pageId?
I have included a link to a jsfiddle for reference: http://jsfiddle.net/cLNmS/