2

In angularjs if we want to change the state, $state.go() and $state.transitionTo() these two things are referred by many people even in tutorial. But what is my doubt is some say $state.go() is good and also recommended. But two do the same process if you look external. for example $state.go('^.create') same as $state.transitionTo('create')

$stateProvider.state('create',
        {
          url: '/create',
          template: '<div></div>',
          controller: 'xyz'
        })

I want to know what is the exact difference about $state.go() and $state.transitionTo();

harishr
  • 17,807
  • 9
  • 78
  • 125
Rajesh
  • 78
  • 2
  • 8

1 Answers1

6

From the source,

$state.go = function go(to, params, options) {
return this.transitionTo(to, params, extend({ inherit: true, relative: $state.$current             }, options));
  };

$state.go just calls transitionTo with inherit and relative set to true. Almost no difference.

Code Whisperer
  • 22,959
  • 20
  • 67
  • 85