Skip to content

Resolve data in child state, but its query depends on a resolved object in the parent state. #151

Closed
@michaelhunziker

Description

@michaelhunziker

Dear all!

I'm having some issues with loading data in a child state. The problem is, that i need to resolve data in my child state which depends on an attribute of an object which was resolved in its parent state. So the hard coded objecttype parameter "APP" below is actually an attribute of an object which was loaded into scope by the parent state. Unfortunately I can't access the object in the parent scope using the following code: $scope.objectType....

$stateProvider
    .state('configurationsWizard.components', {
        url: '/components',
        templateUrl: 'src/app/configurationsWizard/serviceComponents/components.tpl.html',
        controller: 'ServiceComponentsController',
        resolve: {serviceComponents: function ($stateParams, ServiceComponents, $q) {

            var deferred = $q.defer();
            ServiceComponents.query({language:'de',objecttype:'APP'},
                function (response) {
                    deferred.resolve(response);
                }
            );
            return deferred.promise;

        }
        }
    })

How could I solve this problem? I must have missed something because I think it is a common problem to query detail data which depends on master data. Right??

Cheers and thank you in advance!
Michael

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions