Hi, recently i got a problem when i use nav side bar menu:
<ion-side-menus enable-menu-with-back-views="false">
<!-- CONTENT -->
<ion-side-menu-content>
<!-- header bar -->
<!-- the nav bar will be updated as we navigate between views -->
<ion-nav-bar>
<!-- back button, shown if applicable -->
<ion-nav-back-button ng-click="goBack()">
</ion-nav-back-button>
<!-- nav button, shown if applicable -->
<ion-nav-buttons side="left">
<button class="button button-icon button-clear ion-navicon" menu-toggle="left">
</button>
</ion-nav-buttons>
<ion-nav-buttons side="right">
<common-header></common-header>
</ion-nav-buttons>
</ion-nav-bar>
<!-- ROUTING INJECTED HERE: pageContent -->
<ion-nav-view name="pageContent">
</ion-nav-view>
</ion-side-menu-content>
<!-- SIDEMENU -->
<ion-side-menu side="left">
<!-- menu header -->
<ion-header-bar>
<h1 class="title"></h1>
</ion-header-bar>
<!-- menu content -->
<ion-content class='wrap'>
<ion-list>
<ion-item menu-close ui-sref="main.settings({type: 'notification'})">...
</ion-item>
<ion-item menu-close ng-click="signOut()">...
</ion-item>
</ion-list>
</ion-content>
</ion-side-menu>
</ion-side-menus>
Inside the html fragment, i use a directive named ‘common-header’, and the common header controller code is:
.controller('CommonHeaderCtrl', function (ProfileSvc, $scope, $rootScope) {
$rootScope.$on('header:refreshPoints', function() {
...
});
...
})
Inside common header controller, there is a event registered.
The problem is every time when emit event ‘header:refreshPoints’, the event handler will be execute twice. This is caused by nav bar block cached the html fragment which cause the controller loaded twice.
I think when the cache way is not so good, it might cause performance issue, please help to solve the problem, thanks!