AngularJS中$state.transitionTo()和$state.go()之间的区别

前端之家收集整理的这篇文章主要介绍了AngularJS中$state.transitionTo()和$state.go()之间的区别前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
在AngularJS中,我看到有时我们使用$ state.transitionTo(),有时我们使用$ state.go()。任何人都可以告诉我他们有什么不同,什么时候应该使用另一个?
你是指 AngularUI Router吗?如果是这样,wiki specifies the differences

$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 you to easily use an 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. $state.go() is recommended in most situations.

原文链接:https://www.f2er.com/angularjs/147085.html

猜你在找的Angularjs相关文章