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
    }
});

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

I do not know how I put this answer as accepted :-(

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.