Skip to content

Resolving variables into modal with ui.router #13

@Eksrow

Description

@Eksrow

I am trying to use your lib in combination with state resolves of ui-router and my code looks a bit like this:

.state({
    name: 'main',
    url: '/main',
    controller: 'InputViewCtrl',
    templateUrl: 'tpl/overviewInput.html',
    resolve: {
        tasks: function(Shared, TaskService){
            return TaskService.getTasks(Shared.getMonthParameters())
        }
    }
})
.state({
    name: 'main.addtask',
    url: '/addtask',
    onEnter: function(modal, tasks){
        modal.activate(); 
    },
    onExit: function(modal){
        modal.deactivate();
    },
    resolve:{
        modal: function(btfModal){
            return btfModal({
                controller: 'ExternalTaskAddCtrl',
                controllerAs: 'modal',
                templateUrl: 'tpl/partials/externalTaskAdd.html'
            });
        }
    }
})

So as you can see, in my 'main' state I resolve the tasks variable and in my sub-state 'main.addtask' I wish to use this that variable. Now I could easily fix this with:

modal.activate({tasks : tasks});

But that loses the dependency injection in my modal and is directly inserted in the scope. Is there a way I can achieve it that looks similar to what the angular ui-bootstrap modal is doing?[1]

[1] https://github.com/angular-ui/ui-router/wiki/Frequently-Asked-Questions#how-to-open-a-dialogmodal-at-a-certain-state

-edit: link was broken

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions