我有以下状态配置:
.state('test', {
url: '/info',
templateUrl: 'views/test.html',
// reloadOnSearch:false
})
我不想在状态识别中启用重新加载搜索 = false。因为这样就不允许用户更改URL并查看新数据。所以我想把这个参数和ui-sref-opts一起传递。
我在互联网上尝试了足够的搜索,但事实并非如此;t 似乎正在工作:
这是我的 HTML:
<tab ui-sref="test" ui-sref-active="active" active="testingState">
.......
</tab>
我试图用ui-sref-opts传递"reloadOnSearch:false",但这似乎不起作用。
任何人都可以在这里帮助我。
我记得不久前必须这样做,以便在进行/过滤搜索时保存浏览器历史记录。我找到了我使用的帖子,它帮助我解决了这个问题,虽然它有点简陋(https://github.com/angular-ui/ui-router/issues/1079(:
//set the reloadOnSearch on state to false initially in some code block
$state.current.reloadOnSearch = false;
// update query string here
$location.search({"from": 1, "to": 2});
//revert reloadOnSearch on the state!
$timeout(function () {
$state.current.reloadOnSearch = undefined;
});
我相信您应该能够将此代码放在导致页面刷新的任何内容中。