0

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)

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.