AngularJS UI-Router中的ui-sref和$state.go之间的区别
发布时间:2020-12-17 08:30:58 所属栏目:安全 来源:网络整理
导读:ui-sref和$ state.go()之间有什么功能差异吗? ui-sref用于 a … / a和$ state.go(‘someState’)在控制器中使用。 在HTML中,我将使用: a ui-sref="currentState.state1"Link/a 而在函数中,我将使用类似: if(someCondition) { $state.go('currentState.s
ui-sref和$ state.go()之间有什么功能差异吗?
ui-sref用于< a> …< / a>和$ state.go(‘someState’)在控制器中使用。 在HTML中,我将使用: <a ui-sref="currentState.state1">Link</a> 而在函数中,我将使用类似: if(someCondition) { $state.go('currentState.state1'); } 那么,是否需要在$ state.go()之后添加一些东西?假设当前状态是currentState。
ui-sref和$ state.go之间没有功能差异。请参阅文档
Activating a state
所以,这些都是在结束做同样的,我们可以看到在 ... element.bind("click",function(e) { var button = e.which || e.button; if ( !(button > 1 || e.ctrlKey || e.metaKey || e.shiftKey || element.attr('target')) ) { var transition = $timeout(function() { // HERE we call $state.go inside of ui-sref $state.go(ref.state,params,options); }); 它确实调用$ state.go() 也如这里讨论的:ui-sref:
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |