How to $state.go()

My error is in regular expression, really:

.state('company.detail', {
    url : '/{id:\d*}',
    templateUrl : '/admindesktop/templates/company/detail/',
    controller : 'CompanyDetailController'
 })

{id:\d*} worked (integer id).


What would always work is the full state definition:

// instead of this
// $state.go('.detail', {
// use this
$state.go('company.detail', {
    id: $scope.selectedItem.id //selectedItem and id is defined
});

In doc there are defined these options, but they depend on CURRENT state:

to string
Absolute state name or relative state path. Some examples:

  • $state.go('contact.detail') - will go to the contact.detail state
  • $state.go('^') - will go to a parent state
  • $state.go('^.sibling') - will go to a sibling state
  • $state.go('.child.grandchild') - will go to grandchild state

To load the current state. Check this out.

$state.go($state.current, {}, {reload: true}); //second parameter is for $stateParams

Reference