I defined a dynamic state with a given parameter from an a-Tag.
Template:
<a ui-sref-active="active" ui-sref=".item({ itemId: item.Id })">
State definition:
.state('home.item', {
url: '/{itemId}',
component: 'item',
resolve: {
item: function(items, $stateParams) {
return items.find(function(item) {
return item.Id === $stateParams.itemId;
});
}
}
})
In the template theres a ng-repeat which generates a navigation structure. I just want to activate the first link with:
$urlRouterProvider.otherwise(/welcome/{item.Id})
The IDs of the Elements are changing so i cannot hard-code this and i need to get the dynamic value of the first link. Since i dont click anything on load, the state does not know the ID-parameter of the first element an therefore does not select the correct state.
Can anyone help?