ridoansaleh
ridoansaleh

Reputation: 624

Angular-ui-router : Got error when assign number to resolve's property

I use angularjs v1.6.3. I got an error when assign a number to resolve's property of state.

.state('products-new', {
    url: "/rent/whats-new/",
    resolve: {
      pageType: 2, 
    }
    ...
}

This is the error message i have got :

Error: ng:areq
Bad Argument

Argument 'fn' is not a function, got number

Can anyone explain to me why this happen ?

Upvotes: 0

Views: 95

Answers (1)

George
George

Reputation: 6739

As I said in my comment, Resolves should either be a function which returns the value or a string to a service that gets injected. For more information look at the documentation I've linked above. So change your code to the below and all should work.

.state('products-new', {
    url: "/rent/whats-new/",
    resolve: {
        pageType: function () {
            return 2;
        },
    }
}

Upvotes: 1

Related Questions