[SOLVED] Controller is loading twice by using $state.go()

Hi all!

If i’m using $state.go(‘app.home’) my controller appHomeCtrl is loading twice and appCtrl is loading one time again. Can someone help?

$stateProvider
//APP
.state('app', {
 url: '/app',
 cache: false,
 abstract: true,
 templateUrl: 'templates/app.html',
 controller: 'appCtrl',
})
.state('app.home', {
 url: '/home/:id',
 cache: false,
 views: {
  'appContent': {
   templateUrl: 'templates/app/home.html',
   controller: 'appHomeCtrl',
  },
 },
})

I’m having this same issue. Did you figure it out by chance?

Sorry no. But i hope someone can help here. Its very critical at my app cause some stuff loading multiple times (update check, translation service, etc…)

I figured out what is was in my case. I had the controller defined in the routes in app.js as well as in the view itself using ng-controller="…"

//PROFILE .state('app.profile', { url: "/profile", params: { user: {} }, views: { 'menuContent': { templateUrl: "views/app/profile.html", controller: 'ProfileCtrl' } } })
AND

<ion-view class="profile-view" ng-controller="ProfileCtrl">

This was causing it to load twice - so I just removed it from the template and everything is back to normal.

Ok. :slightly_smiling:

For me it works if i set the reload-parameter to false. Like: $state.go(theState, theParams, {reload: false});