1

I'm using $state.go("titulos", params) to load the titulos page, in which case the parent controller (emissao) is not loaded again. But when I call the grandchildren $state.go("titulos.fluxos", params) the parent controller (titulos) is loaded again. I do not want this to happen, because the parent controller is already loaded, this is an unwanted behavior. I do not know why the first child works perfectly without loading the parent, but for the grandchild (titulos.fluxos) unnecessarily load his parent (titulos). How could I solve this? please.

$stateProvider.state('emissao', {
    url: '/emissao',
    views: {
        'main': {
            controller: 'emissaoCtrl',
            templateUrl: 'view/emissao.html'
        }
    },
    resolve: {
        emissoes: function (cadastroAPI) {
            return cadastroAPI.listar('emissao');
        }
    }
});

$stateProvider.state('titulos', {
    parent: 'emissao',
    url: '/titulos',
    controller: 'titulosCtrl',
    templateUrl: 'view/titulo.html',
    resolve: {
        titulos: function (cadastroAPI, $stateParams) {
            return cadastroAPI.listarTitulos($stateParams.parent.obj);
        }
    },
    params: {
        parent: null,
        container: null
    }
});

$stateProvider.state('titulos.fluxos', {
    url: '/fluxos',
    controller: 'fluxosCtrl',
    templateUrl: 'view/fluxo.html',
    resolve: {
        fluxos: function (fluxoAPI, $stateParams) {
            return fluxoAPI.listar($stateParams.parent.obj.Id);
        }
    },
    params: {
        parent: null,
        container: null
    }
});
evbell
  • 97
  • 1
  • 7

1 Answers1

1

I discovered the problem! Actually, normal behavior does not load the parent controller, my problem is that the 'params' parameters had the same name 'parent' both in the parent controller 'titulos' and in the child 'fluxos' and this was causing an unnecessary call to the parent controller.

evbell
  • 97
  • 1
  • 7