Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolving variables into modal with ui.router #13

Open
Eksrow opened this issue Apr 30, 2014 · 1 comment
Open

Resolving variables into modal with ui.router #13

Eksrow opened this issue Apr 30, 2014 · 1 comment

Comments

@Eksrow
Copy link

Eksrow commented Apr 30, 2014

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

@stryju
Copy link

stryju commented Apr 30, 2014

i'd go with a service wrapped around this particular modal that would return a promise :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants