Resolving variables into modal with ui.router
Eksrow opened this issue · comments
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]
-edit: link was broken
i'd go with a service wrapped around this particular modal that would return a promise :-)