We currently have this dynamic routing (don't mind sytax errors, transformed from CoffeeScript by hand):
angular
.module 'App'
.config(function ($stateProvider) {
$stateProvider
.state(
'settings.integrations.details',
{
url: '/integrations/:id/:action',
views: {
"entity_view": {
controllerProvider: function ($stateParams) {
[...]
return controllerName;
}
}
}
resolve: {
dep1: function ($stateParams, Dep1Repository) {
if ($stateParams.id != 'ab') {
return null;
}
return Dep1Repository.load();
},
dep2: function ($stateParams, Dep2Repository) {
if ($stateParams.id != 'cd') {
return null;
}
return Dep2Repository.load();
}
}
As you can see there is this part if ($stateParams.id != '..')
and it repeats throught other resolve functions.
Is there any way to provide "factory" method, so I can manage it more easily?
Like some provided that would be called on every transition to change resolve list?
resolve: ResolveProvider.getRoute($stateParams.id)