简体   繁体   English

angularjs uib-tab延迟加载

[英]angularjs uib-tab lazy loading

I have a uib-tab with a heading an an ng-click method that loads the actual content by switching a boolean variable as follows. 我有一个uib选项卡,标题为ng-click方法,该方法通过如下切换布尔变量来加载实际内容。

<uib-tab class="height-full">
    <uib-tab-heading ng-click="vm.loadTab(2)">
                Rights
     </uib-tab-heading>
      <div>
      <div ng-if="vm.active_tab == 2" ng-include="'../partials/partialview.html'"></div>
      </div>
</uib-tab>

This doesn't have consistent behaviour, some times the loadTab it's not executed at all and the tab is indeed been loaded, how can I solve this ? 这没有一致的行为,有时loadTab根本没有执行,并且选项卡确实已加载,我该如何解决呢? can I prevent the tab-content from been loaded and wait for the loadTab to execute first. 我可以防止制表符内容被加载并等待loadTab首先执行。

I found this solution how to lazy load Angular UI tabs and pills described in more detail here . 我发现此解决方案如何延迟加载Angular UI选项卡和药丸,进行了详细介绍。

Load the script files into your application. 将脚本文件加载到您的应用程序中。

<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-ui-bootstrap-bower/ui-bootstrap-tpls.js"></script>
<script src="bower_components/angular-ui-bootstrap-tabs-include/lib/angular-ui-bootstrap-tabs-include.js"></script>

For each of the tabs in your tabset, you can now include a tab-include attribute that points to a partial which will be loaded into the tab pane when selected. 现在,对于选项卡集中的每个选项卡,您都可以包括一个tab-include属性,该属性指向一个部分,当选中该部分时,该部分将被加载到选项卡窗格中。

<tabset>
    <tab heading="Foo" tab-include="'partials/foo.html'"></tab>
    <tab heading="Bar" tab-include="'partials/bar.html'"></tab>
</tabset>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM