Routing path settings: Structured.text; Structured is the first layer of routing, text is the second layer of routing;
The problem is that when $state.transitionto is routed to the second tier, the controller of structured is also executed once, causing the page control to reload refreshed.
$state. Transitionto ( "Structured.text", {args: $stateParams}, {reload:false});
Checked GitHub to see https://github.com/angular-ui/ui-router/issues/1612, said the problem has been fixed, but set up reload:stateobj and no eggs.
Christopherthielen commented on 8 Mar 2015
I think this makes sense and was a good idea. I ' d like to omit the second reloadstate parameter, and overload the existing reload parameter.
{ reload: true } Reloads all,
{ reload: ‘foo.bar‘ } Reloads Top.bar, and any children
{ reload: stateObj } Reloads state found in stateobj, and any children
Squash your commits and set your commit message to match the contributor guidelines. If @nateabeleconcurs, I think we ' ll merge this in. |
Until I saw Https://stackoverflow.com/questions/21105528/difference-between-state-transitionto-and-state-go-in-angular-ui-router.
$state. Go (to [, Toparams] [, Options])
Returns a Promise representing the state of the transition.
Convenience method for transitioning to a new state. $state.go
calls $state.transitionTo
internally but automatically sets options to { location: true, inherit: true, relative: $state.$current, notify: true }
. This allows your to easily use a absolute or relative to path and specify only the parameters you ' d like to update (while Letting unspecified parameters inherit from the current state).
$state. Transitionto (To, toparams [, Options])
Returns a Promise representing the state of the transition.
Low-level method for transitioning to a new state. $state.go()
uses transitionTo
internally. is recommended in the most $state.go()
situations.
$state. Transitionto is the underlying method, with $state. Go is implemented with it,$state. Go sets Some default parameters, so use the $state. Go tried, unexpectedly success;
Debug looked at the original default options inherit:true and Reload:false common problems raised:
Error notation 1:
$state. Transitionto ( "Structured.text", {args: $stateParams}, {reload:false});
Cause: The route is written in level two, and the structured controller will be executed repeatedly
Error notation 2:
$state. Transitionto ( ". Text", {args: $stateParams}, {reload:false});
Cause: Relative not set and inherit default is False
Correct wording:
$state. Transitionto ( ". Text", {args: $stateParams}, {reload:false inherit:true, relative: " Structured "});
Or
$state. Go ( ". Text", {args: $stateParams}, false});
Indeed recommended the use of $state.go, with the $state.transitionto bottom method, the options to be correct, problem solving, engaged in a half-day event, this API design let people depressed.
Angularjs UI router, routing nested parent controller execution issues