user4700919
user4700919

Reputation:

AngularJS : multiple resolves in ui.router

i'm trying achieve something like this :

 $stateProvider.state('app', {
        url: "/app",
        templateUrl: "assets/views/app.html",
        resolve: {
            authorize: ['authorization',
                function(authorization) {
                    return authorization.authorize();
                }
            ],
            loadSequence: loadSequence('chartjs', 'chart.js', 'chatCtrl')
        },
        abstract: true

resolving "authorize" then "LoadSequence" function, but the error i get is confusing and i can't figure out how to do it properly :

Error: ng:areq Bad Argument Argument 'fn' is not a function, got Object

Best regards.

Upvotes: 3

Views: 291

Answers (1)

MBielski
MBielski

Reputation: 6620

I think you need to wrap the second item in resolve in a function like you did the first one:

$stateProvider.state('app', {
    url: "/app",
    templateUrl: "assets/views/app.html",
    resolve: {
        authorize: ['authorization',
            function(authorization) {
                return authorization.authorize();
            }
        ],
        loadSequence: function(){
            return loadSequence('chartjs', 'chart.js', 'chatCtrl');
        }
    },
    abstract: true

Also, if loadSequence does not return a promise, it needs to.

Upvotes: 1

Related Questions