Skip to content

Can multiple parent states share single child state? #1072

@xmlking

Description

@xmlking

Looking for suggestions to implement following use case: support for multiple patent states sharing single child state.

I have a nested view with search UI, list results & search results table and item details view shared with search and list states.

.state('drugs', {
    abstract: true,
    url: '/drugs',
    access: {allowAnonymous: false, roles: [USER_ROLES.DATA_ADMIN,USER_ROLES.IT_ADMIN]},
    // Note: abstract still needs a ui-view for its children to populate.
    // You can simply add it inline here.
    template: '<ui-view/>'
})
.state('drugs.list', {
    url: '/list',
    templateUrl: 'views/dashboard/drugs.html',
    controller: 'DrugController',
    resolve: {
        drugs: ['DrugService','$stateParams', function (DrugService,$stateParams) {
            return DrugService.listDrugs();
        }]
    }
})
.state('drugs.search', {
    url: '/search',
    templateUrl: 'views/dashboard/drugs.html',
    controller: 'DrugController',
    resolve: {
        drugs: ['DrugService','$stateParams', function (DrugService,$stateParams) {
            return DrugService.searchDrugs();
        }]
    }
})
//FIXME : wish UI-Router supports multiple inheritance  for child state to avoid duplicate code
.state('drugs.list.detail', {
    url: '/:drugId',
    access: {allowAnonymous: false, roles: USER_ROLES.SUPER_ADMIN},
    templateUrl: 'views/dashboard/drugs.detail.html',
    controller: 'DrugDetailController',
    resolve: {
        drug:['DrugService', '$stateParams', function(DrugService, $stateParams){
            return DrugService.getDrug($stateParams.drugId);
        }]
    }
})
.state('drugs.search.detail', {
    url: '/:drugId',
    access: {allowAnonymous: false, roles: USER_ROLES.SUPER_ADMIN},
    templateUrl: 'views/dashboard/drugs.detail.html',
    controller: 'DrugDetailController',
    resolve: {
        drug:['DrugService', '$stateParams', function(DrugService, $stateParams){
            return DrugService.getDrug($stateParams.drugId);
        }]
    }
})

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