Cannot read property 'enableMenuWithBackViews' of undefined

I am struggling with error for last few days and could find fix for it.
I have a side menu project
I have called a registration form and redirecting it to a home screen please find below my code.

app.js

.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state(‘app’, {
url: “/app”,
abstract: true,
templateUrl: “templates/menu.html”,
controller: ‘MainCtrl’
})
.state(‘app.welcome’, {
url: “/welcome”,
views: {
‘menuContent’: {
templateUrl: “templates/welcome.html”,
controller: ‘HomeCtrl’
}
}
})
.state(‘app.home’, {
url: “/home”,
views: {
‘menuContent’: {
templateUrl: “templates/home.html”,
controller: ‘HomeCtrl’
}
}
})
.state(‘app.order’, {
url: “/order”,
views: {
‘menuContent’: {
templateUrl: “templates/order.html”,
controller: ‘OrderCtrl’
}
}
})
// if none of the above states are matched, use this as the fallback
$urlRouterProvider.otherwise(‘/app/welcome’);
});

home.js

$scope.refresh = function() {
if (globalVars.registeredApp) {
$ionicSideMenuDelegate.canDragContent(true);
$location.path(“app/home”);
} else {
$ionicSideMenuDelegate.canDragContent(false);
$location.path(“app/welcome”);
}
}

It seems from debugging that the page gets called multiple times and on second run the error happens
All help is appretiated…

Could you put this into a codepen

I was having the same issue, when a new view loaded I got this error. I commented this out in ionic.bundle.js to “fix” it:
Starting with line 50161
if (viewData.enableBack) {
var sideMenuCtrl = $element.inheritedData(’$ionSideMenusController’);
if (!sideMenuCtrl.enableMenuWithBackViews()) {
$element.addClass(‘hide’);
}
} else {
$element.removeClass(‘hide’);
}

Any updates?

Or is the fix suggested by Bjorn2Run the suggested way to go? Should we not just check for the var sideMenuCtrl in

if (!sideMenuCtrl.enableMenuWithBackViews()) ==>

if (sideMenuCtrl && !sideMenuCtrl.enableMenuWithBackViews()) {

?

same here… my views transitions are excruciatingly slow (like you tap something and you wait a good 10 seconds to have the page showing out of nowhere) I’m trying to optimise things a little, so all the pages with no need for the sidemenu don’t carry all the DOM anymore… (not sure it’ll do any good but I’m trying…)

so for now, I have as routing:
app (abstract with just template: ‘’)
app.sidemenu (here all the sidemenu things)
app.sidemenu.tabs (here I have a 2 tab navigation)
app.sidemenu.tabs.something (here a list of things to display in the first tab)
app.tabs.somethingitem (here the detail of the things I was displaying before, no sidemenu and 3 tabs (different ones))

if I navigate to app.tabs.somethingitem and subsequent views, I constantly get this error! It works though (didn’t try the speed improvement but functionality wise it works)

I’ve got a CodePen that illustrates this. It is based off a nightly CodePen of side menus with navigation. What I’ve done is add a separate state abstract state (which does not use sidemenu at all), with two child states.

To trigger:

  1. Click ‘Go to sub1’
  2. Click ‘Go to sub2’. This will trigger the error.

Here is a CodePen that fixes it. I’ve removed the ion-nav-buttons element from other.html. In particular, it is the presence of the menu-toggle directive.