Skip to content

Using optional parameters reloads controller when moving away from state #1673

Closed
@eranimo

Description

@eranimo

I define a state like this:

.state('game.sector', {
    url: '/universe/sector/:sector_id_id/:x/:y',
    params: {
        system_id: null,
        x: {
            value: 1,
            squash: true
        },
        y: {
            value: 1,
            squash: true
        }
    },
    controller: 'SectorCtrl',
    templateUrl: 'modules/sector/views/sector.html'

})

With two optional parameters and one required.
I have a function that periodically updates the X and Y optional parameters like so:

$state.transitionTo('game.sector', {
    sector_id: $scope.sector_id,
    x: x
    y: y
}, {
    location: 'replace',
    relative: $state.$current,
    notify: false
});

The problem is that after I update the optional parameters, and after I trigger any kind of state change (ui-sref or $state.go) the state transition sometimes fails.
I'm also listening on every UI Router even on the $rootScope, but this failure is never reported to those events. Clicking on a ui-sref link simply reloads the current controller.
Any ideas why this may happen?

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions