Closed zhanghuanchong closed 8 years ago
I have this issue as well. It appears that the tabs controller runs for the same number of times for which you have tabs. ie: 2 tabs = 2 executions, 3 tabs = 3 executions and so on.
On inspection it appears to be injecting the
Hi guys... I had to solve this issue as well. The issue is that the <ui-view>
directive which is rendered by ui-router is placed under each tab in the default template.
To solve, we used a custom template (just use the attribute template-url in the tabs directive), that did a simple check:
<ui-view ng-if="activeTab == $index"></ui-view>
You can currently use tabs.active
instead of activeTab
(see my open issue to address the activeTab naming: https://github.com/rpocklin/ui-router-tabs/issues/75)
Plunkrs would be useful here. Keep in mind there was a breaking change in v2.0.0
changing the default template to include a <ui-view>
element. If you have upgraded and using the default template most likely you have duplicate <ui-view>
elements causing the symptoms you mention.
I have found a bug in the placement of the <ui-view>
element in the default template so i'll push that as v2.0.2
, let me know if that fixes it.
v2.0.2 solved the issue for me
Thank you Robert, the v2.0.2 works! 👍
Yes, it solved this issue, but now ui-view not inside .tab-content and .tab-pane. And tab template has no tab variable :(
After clicking on the 2nd tab, the code in the tab's controller runs 4 times.
I also have a tabs with only 2 tab page, and the controller of the active one runs 2 times.
Can you help?