7
改变
网址我有一个参数定义路线:
$stateProvider
.state('item', {..})
.state('item.view', {
url: 'item/:id'
template: '...',
controller: '...'
});
虽然已经在item.view状态,我想与切换网址
$state.go('item.view', {id: 'someId'})
无需重新加载页面。我曾尝试过:
$state.go('item.view', {id: 'someId'}, {notify: false});
$state.go('item.view', {id: 'someId'}, {notify: false, reload: false});
两者仍然会导致页面重新加载。我想我可能会运行到这里描述的问题:https://github.com/angular-ui/ui-router/issues/1758
看看这个SO帖子:[link](http://stackoverflow.com/questions/23585065/angularjs-ui-router-change-url-without-reloading-state)看来你可以使用'$ state.transitionTo'(而不是'$ state.go')并设置可选参数以避免重载。在该链接中的一个评论(具有最高数量的选票)提示如下:'$ state.transitionTo('。detail',{id:newId},{location:true,inherit:true,relative:$ state。 $ current,notify:false})所以基本上设置通知为false和位置为真 - 评论时间70年01月01日原作者:Arjen de Vries –