Skip to content

$transitions when using to and from not working #2963

@ilDon

Description

@ilDon

Issue

  • ui-router version: 1.0.0.beta1
  • expected behaviour: when using $transitions, callback function is expected to be executed when to and from parameters are matched
  • actual behaviour: callback is never executed.

Description

I have encountered a problem when using $transitions and declaring the to and from parameters.

The code in the callback was never executed:

$transitions.onSuccess( { to: 'acontrollerbasedstate', from: '*' }, function() {
    // I've also tried { to: '*', from: '*' }
    console.log('running');
    // do stuff
});

I've also testes all methods:

$transitions.onBefore( { to: '*', from: '*' }, function() {
  console.log('onBefore');
});
$transitions.onEnter( { to: '*', from: '*' }, function() {
  console.log('onEnter');
});
$transitions.onError( { to: '*', from: '*' }, function() {
  console.log('onError');
});
$transitions.onExit( { to: '*', from: '*' }, function() {
  console.log('onExit');
});
$transitions.onFinish( { to: '*', from: '*' }, function() {
  console.log('onFinish');
});
$transitions.onRetain( { to: '*', from: '*' }, function() {
  console.log('onRetain');
});
$transitions.onStart( { to: '*', from: '*' }, function() {
  console.log('onStart');
});
$transitions.onSuccess( { to: '*', from: '*' }, function() {
  console.log('onSuccess');
});

Unfortunately nothing ever gets printed in the console.

I thought I was doing something wrong, which might well be the case, so I posted on SO this question.

As I had no answers, I made some tests, and I found out that without declaring to or from, it works:

$transitions.onStart( {}, myFunction);

$transitions.onSuccess({}, function(){
    // here I use $scope.current.name, which for my purposes, works fine for now
});

Could it be a bug?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions