角UI路由器保持标签之间的状态 [英] angular ui-router maintaining state between tabs
问题描述
想知道在标签之间preserve状态的最佳方式。我使用的引导标签和角度UI的路由器。我有一个谷歌地图的标签之一,并且不希望重新加载地图时用户选择该选项卡。请指教。
Would like to know the best way to preserve state between tabs. I use bootstrap tabs and angular ui-router. I've a google map in one of the tabs and don't want to reload the map when user selects that tab. Please advise.
感谢
推荐答案
我觉得你在找什么这个问题进行了讨论:的 https://github.com/angular-ui/ui-router/issues/63
I think what you are looking for is discussed in this issue: https://github.com/angular-ui/ui-router/issues/63
他们大多是讨论内部框架,但我相信同样应该保持谷歌地图。不幸的是在线程中,他们决定这是不是应该在核心版本中实现。我还没有尝试过他们提供的(如果我得到一个机会,我会让你知道如何去)的指令,但你可以得到的东西与合作。
They are mostly discussing iframes but I believe the same should hold for Google Maps. Unfortunately in the thread they decided that this isn't something that should be implemented in the core release. I haven't tried out the directive they provide (if I get a chance I'll let you know how it goes) but you may be able to get something working with that.
其实我也碰到过你有确切的问题。我的解决方案是使用样式按钮作为我的标签和NG-显示在地图选项卡:
I have actually come across the exact problem you had. My solution was to use styled buttons as my tabs and ng-show for the map tab:
<div id="info-btns">
<button class="btn" ng-model="view" btn-radio="'info'">
Info
</button>
<button class="btn" ng-model="view" btn-radio="'map'" ng-click="loadMap()">
Map
</button>
</div>
<div class="content" ng-show="view != map">
<div ui-view="info"></div>
</div>
<div id="map-container" ng-show="view == 'map'">
<div id="map" class="content" sitemap>
</div>
</div>
NG-节目简单地使用显示:无隐藏地图,因此不会引起刷新。您需要将触发加载地图在第一时间它不是隐藏否则会呈现不正确,因此 loadMap()
如果我有机会,我会成立了这个的jsfiddle在实践中。
If I get a chance I'll set up a jsfiddle of this in practice.
这篇关于角UI路由器保持标签之间的状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!