I've got a collection page with a navigation on the left and a bunch of records on the right. Each navigation item corresponds to a record. I want the user to be able to click a nav item on the left and then scroll to the record. Plus the nav item and record should have a 'selected' state.
The URL /stuff/4?selectedRecord=5 should get me all the records of collection id 4 and select record nummer 5.
I got this working with ui-sref on my nav/record items, and the state provider below. When I click on a nav item, the url and states change.
But when I change the url from /stuff/4?selectedRecord=5 to /stuff/4?selectedRecord=6, nothing happens. No $stateChangeStart is fired...
$stateProvider
// The stuff index: /stuff
.state('stuff', {
url: '/stuff',
abstract : true,
templateUrl: 'app/stuff/stuff.html' // wrapper
})
// Stuff detail page.
.state('stuff.detail', {
url: '/{stuffId}',
templateUrl: 'app/stuff/stuff.detail.html',
controller: 'StuffDetailController'
})
// Stuff detail page with a record selected
.state('stuff.detail.selectedRecord', {
url: '?selectedRecord'
})
This is my sref nav item, which works:
<li ui-sref="stuff.detail.selectedRecord({selectedRecord:record.id})"
ui-sref-active="selected">Works</li>
Edit: The exact same code works if I change the url of the selectedRecord to:
url: '/select/:selectedRecord'